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/05/07 14:50:35 UTC
svn commit: r772669 [5/7] - in /incubator/kato/trunk: HprofBinaryReaderPOC/
HprofBinaryReaderPOC/.settings/ HprofBinaryReaderPOC/META-INF/
HprofBinaryReaderPOC/bin/ HprofBinaryReaderPOC/bin/org/
HprofBinaryReaderPOC/bin/org/apache/ HprofBinaryReaderPOC...
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/editors/DumpViewer.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/editors/DumpViewer.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/editors/DumpViewer.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/editors/DumpViewer.java Thu May 7 14:50:21 2009
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * 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.ui.editors;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.kato.common.ClassSummary;
+import org.apache.kato.common.IViewMonitor;
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.IJavaClass;
+import org.apache.kato.hprof.IJavaStack;
+import org.apache.kato.hprof.IJavaStackFrame;
+import org.apache.kato.hprof.IJavaThread;
+import org.apache.kato.hprof.datalayer.HProfFile;
+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.ui.Activator;
+import org.apache.kato.hprof.ui.DumpEditorInput;
+import org.apache.kato.hprof.ui.HProfSource;
+import org.apache.kato.hprof.ui.factory.HeapDumpsRecordViewerFactory;
+import org.apache.kato.hprof.ui.factory.LoadedClassesViewerFactory;
+import org.apache.kato.hprof.ui.factory.LoadedThreadsViewerFactory;
+import org.apache.kato.hprof.ui.factory.RecordsViewerFactory;
+import org.apache.kato.hprof.ui.factory.StackTraceViewerFactory;
+import org.apache.kato.hprof.ui.factory.UTF8RecordsViewerFactory;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ILazyContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.progress.IProgressService;
+
+public class DumpViewer extends MultiPageEditorPart {
+
+
+ HProfView view=null;
+
+
+ private HProfRecordFormatter formatter=null;
+
+ @Override
+ public void dispose() {
+
+ super.dispose();
+ }
+
+
+ private Composite mainPanel=null;
+
+ public void init(IEditorSite site, IEditorInput input)
+ throws PartInitException {
+
+ if(input instanceof FileEditorInput) {
+ try {
+ input=convertInput((FileEditorInput)input);
+ } catch(IOException ioe) {
+ throw new PartInitException("failed to load dump",ioe);
+ }
+ }
+
+ if (!(input instanceof DumpEditorInput)) {
+
+ throw new PartInitException(
+ "Invalid Input: Must be DumpEditorInput not "+input); // TODO a copy
+ }
+
+
+ super.init(site, input);
+
+}
+
+ /**
+ * Converts file input to required editor input
+ *
+ * @param input
+ * @return
+ */
+ private IEditorInput convertInput(FileEditorInput input) throws IOException {
+
+ final IPath fileLocation=input.getPath();
+ final HProfSource source=new HProfSource(fileLocation.toFile());
+
+ IWorkbench wb = PlatformUI.getWorkbench();
+ IProgressService ps = wb.getProgressService();
+ try {
+ ps.busyCursorWhile(new IRunnableWithProgress() {
+ public void run(IProgressMonitor pm) {
+ Activator.getDefault().load(pm,source);
+ pm.beginTask("Reading data", 1);
+ HProfFile dump=source.getDump();
+ view=new HProfView(dump);
+ view.open(new IViewMonitor(){
+
+ @Override
+ public void error(IOException e) {
+
+
+ }});
+
+ pm.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ DumpEditorInput dtfjInput=new DumpEditorInput(source);
+
+ return dtfjInput;
+
+ }
+
+ @Override
+ public boolean isDirty() {
+
+ return false;
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+
+ return false;
+ }
+
+
+ @Override
+ public void setFocus() {
+ if(mainPanel!=null) mainPanel.setFocus();
+
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ // nothing to do
+
+ }
+
+ @Override
+ public void doSaveAs() {
+ // nothing to do
+
+ }
+
+ @Override
+ protected void createPages() {
+
+ DumpEditorInput in=(DumpEditorInput) getEditorInput();
+ HProfSource source=in.getSource();
+
+
+ createMainPage();
+ createRecordsPage();
+ createUTF8RecordsPage();
+ createLoadedClassesPage();
+ createThreadsPage();
+ createStackTracePage();
+
+ createHeapDumpRecordsPage();
+
+
+ }
+
+ private void createHeapDumpRecordsPage() {
+ Composite parent=getContainer();
+ TableViewer page=HeapDumpsRecordViewerFactory.createViewer(parent,view);
+ getSite().setSelectionProvider(page);
+ int index = addPage(page.getTable());
+ setPageText(index, "Heap Records");
+
+ }
+
+ private void createStackTracePage() {
+ Composite parent=getContainer();
+ Composite page=StackTraceViewerFactory.createViewer(parent, view);
+
+
+
+ int index = addPage(page);
+ setPageText(index, "Stack Traces");
+
+ }
+
+ private void createThreadsPage() {
+
+ Composite parent=getContainer();
+ Composite page=LoadedThreadsViewerFactory.createViewer(parent, view);
+ int index = addPage(page);
+ setPageText(index, "Threads");
+
+ }
+
+
+ private void createUTF8RecordsPage() {
+ Composite parent=getContainer();
+ Composite page=UTF8RecordsViewerFactory.createViewer(parent, view);
+ int index = addPage(page);
+ setPageText(index, "UTF8 Strings");
+
+ }
+ private void createLoadedClassesPage() {
+ Composite parent=getContainer();
+ Composite page=LoadedClassesViewerFactory.createViewer(parent, view);
+ int index = addPage(page);
+ setPageText(index, "Loaded classes");
+
+ }
+
+ private void createRecordsPage() {
+ Composite parent=getContainer();
+ TableViewer viewer=RecordsViewerFactory.createViewer(parent, view);
+ getSite().setSelectionProvider(viewer);
+
+ viewer.setInput(view);
+ int index = addPage(viewer.getTable());
+ setPageText(index, "Records");
+
+ }
+ private void createMainPage() {
+
+ Composite parent=getContainer();
+
+ Composite sash = new Composite(parent, SWT.NONE);
+ sash.setLayout(new FillLayout());
+ sash.setLayoutData(new GridData(GridData.FILL_BOTH));
+ SashForm sashForm = new SashForm(sash, SWT.VERTICAL);
+ sashForm.SASH_WIDTH = 20;
+
+ Table t=new Table(sashForm,SWT.BORDER);
+ t.setLinesVisible(true);
+
+ TableColumn column=new TableColumn(t,SWT.LEFT );
+ column.setWidth(100);
+ column=new TableColumn(t,SWT.LEFT);
+ column.setWidth(100);
+ TableItem item=new TableItem(t,SWT.NONE);
+ item.setText(new String[]{"Main records",""+view.getFile().getRecordCount()});
+
+ item=new TableItem(t,SWT.NONE);
+ item.setText(new String[]{"Heap records",""+view.getHeapRecord().getSubRecordCount()});
+
+
+ // get summary info
+ ClassSummary summary=view.getRecordSummary();
+
+ t=new Table(sashForm,SWT.BORDER);
+ t.setLinesVisible(true);
+ t.setHeaderVisible(true);
+
+
+ column=new TableColumn(t,SWT.LEFT );
+ column.setWidth(600);
+ column.setText("Tag Name");
+
+ column=new TableColumn(t,SWT.RIGHT);
+ column.setWidth(80);
+ column.setText("Occurs");
+
+ for(String tag:summary) {
+ Integer count=summary.getCount(tag);
+ item=new TableItem(t,SWT.NONE);
+ item.setText(new String[]{tag,""+count});
+ }
+
+ int index = addPage(sash);
+ setPageText(index, "Main");
+
+
+
+ }
+
+
+
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HProfRecordPropertySourceFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HProfRecordPropertySourceFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HProfRecordPropertySourceFactory.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HProfRecordPropertySourceFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.ui.factory;
+
+import org.apache.kato.hprof.datalayer.IHProfRecord;
+import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
+import org.apache.kato.hprof.datalayer.HProfFile.GCClassHeapDumpRecord;
+import org.apache.kato.hprof.ui.propertysource.GCClassHeapDumpRecordPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+public class HProfRecordPropertySourceFactory {
+
+
+ public static IPropertySource createPropertySource(IHeapDumpHProfRecord dumpRecord,int index,IHProfRecord record) {
+
+ if(record instanceof GCClassHeapDumpRecord) {
+ return new GCClassHeapDumpRecordPropertySource(dumpRecord,(GCClassHeapDumpRecord) record,index);
+ }
+
+ return null;
+ }
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HeapDumpsRecordViewerFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HeapDumpsRecordViewerFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HeapDumpsRecordViewerFactory.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/HeapDumpsRecordViewerFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.ui.factory;
+
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
+import org.apache.kato.hprof.ui.HProfSubRecordHandle;
+import org.apache.kato.hprof.ui.provider.AbstractHProfLazyContentProvider;
+import org.apache.kato.hprof.ui.provider.HeapDumpRecordLabelProvider;
+import org.apache.kato.hprof.ui.provider.StringArrayLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class HeapDumpsRecordViewerFactory {
+
+
+ public static TableViewer createViewer(Composite parent,HProfView view) {
+
+ TableViewer viewer=new TableViewer(parent,SWT.BORDER | SWT.VIRTUAL);
+ Table table = viewer.getTable();
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+
+ TableColumn column=new TableColumn(table,SWT.RIGHT,0);
+ column.setText("#");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.RIGHT,1);
+ column.setText("Location");
+ column.setWidth(50);
+ column=new TableColumn(table,SWT.RIGHT,2);
+ column.setText("Length");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.LEFT,3);
+ column.setText("Class");
+ column.setWidth(200);
+
+ column=new TableColumn(table,SWT.LEFT,4);
+ column.setText("Data");
+ column.setWidth(500);
+
+
+ viewer.setContentProvider(new AbstractHProfLazyContentProvider(viewer,view){
+
+ @Override
+ public int getTableSize(HProfView dumpViewer) {
+ return dumpViewer.getHeapRecord().getSubRecordCount();
+ }
+
+ @Override
+ public void updateEntry(TableViewer tableViewer,
+ HProfView dumpViewer, int index) {
+
+
+ IHeapDumpHProfRecord heap=dumpViewer.getHeapRecord();
+ HProfSubRecordHandle handle=new HProfSubRecordHandle(index,heap);
+
+ tableViewer.replace(handle, index);
+ }});
+
+ viewer.setLabelProvider(new HeapDumpRecordLabelProvider(view));
+ viewer.setInput(view);
+
+ return viewer;
+ }
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedClassesViewerFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedClassesViewerFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedClassesViewerFactory.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedClassesViewerFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.ui.factory;
+
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.IJavaClass;
+import org.apache.kato.hprof.ui.provider.AbstractHProfLazyContentProvider;
+import org.apache.kato.hprof.ui.provider.StringArrayLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class LoadedClassesViewerFactory {
+ public static Composite createViewer(Composite parent,HProfView view) {
+ TableViewer viewer=new TableViewer(parent,SWT.BORDER | SWT.VIRTUAL);
+ Table table = viewer.getTable();
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+ TableColumn column=new TableColumn(table,SWT.LEFT,0);
+ column.setText("OBJID");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.RIGHT,1);
+ column.setText("Serial");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.RIGHT,2);
+ column.setText("Stack");
+ column.setWidth(50);
+ column=new TableColumn(table,SWT.LEFT,3);
+ column.setText("Class Name");
+ column.setWidth(500);
+
+ viewer.setContentProvider(new AbstractHProfLazyContentProvider(viewer,view){
+
+ @Override
+ public int getTableSize(HProfView dumpViewer) {
+
+ return dumpViewer.getLoadedClassCount();
+ }
+
+ @Override
+ public void updateEntry(TableViewer tableViewer,
+ HProfView dumpViewer, int index) {
+ IJavaClass clazz=dumpViewer.getLoadedClass(index);
+ String[] data=new String[] {HProfRecordFormatter.toHex(clazz.getClassObjectID()),
+ ""+clazz.getClassSerialNumber(),
+ ""+clazz.getStackTraceSerialNumber(),
+ clazz.getClassName()
+ };
+ tableViewer.replace(data, index);
+
+ }});
+
+ viewer.setLabelProvider(new StringArrayLabelProvider());
+ viewer.setInput(view);
+
+ return table;
+ }
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedThreadsViewerFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedThreadsViewerFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedThreadsViewerFactory.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/LoadedThreadsViewerFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * 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.ui.factory;
+
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.IJavaStack;
+import org.apache.kato.hprof.IJavaStackFrame;
+import org.apache.kato.hprof.IJavaThread;
+import org.apache.kato.hprof.ui.provider.AbstractHProfLazyContentProvider;
+import org.apache.kato.hprof.ui.provider.AbstractHProfViewLabelProvider;
+import org.eclipse.jface.viewers.ILazyContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class LoadedThreadsViewerFactory {
+
+
+ public static Composite createViewer(Composite parent,HProfView dumpViewer) {
+
+
+ // Create the SashForm
+ Composite sash = new Composite(parent, SWT.NONE);
+ sash.setLayout(new FillLayout());
+ sash.setLayoutData(new GridData(GridData.FILL_BOTH));
+ SashForm sashForm = new SashForm(sash, SWT.VERTICAL);
+
+ // Change the width of the sashes
+ sashForm.SASH_WIDTH = 20;
+
+ TableViewer stackviewer=buildStackViewerTable(sashForm);
+ TableViewer viewer=buildThreadViewerTable(sashForm,dumpViewer,stackviewer);
+
+ return sash;
+ }
+
+private static TableViewer buildStackViewerTable(SashForm sashForm) {
+
+ final TableViewer viewer=new TableViewer(sashForm,SWT.BORDER | SWT.VIRTUAL);
+ final Table stack = viewer.getTable();
+
+ stack.setLinesVisible(true);
+ stack.setHeaderVisible(true);
+
+
+ TableColumn column=new TableColumn(stack,SWT.LEFT,0);
+ column.setText("Class");
+ column.setWidth(100);
+ column=new TableColumn(stack,SWT.LEFT,1);
+ column.setText("Method");
+ column.setWidth(100);
+ column=new TableColumn(stack,SWT.RIGHT,2);
+ column.setText("Line");
+ column.setWidth(100);
+
+
+ viewer.setLabelProvider(new AbstractHProfViewLabelProvider(){
+
+ @Override
+ public String getColumnText(Object obj, int index) {
+ IJavaStackFrame frame=(IJavaStackFrame) obj;
+ switch (index) {
+ case 0: return frame.getMethodClass().getClassName();
+ case 1: return frame.getMethodName();
+ case 2: return ""+frame.getLineNumber();
+ }
+ return null;
+ }} );
+
+ viewer.setContentProvider(new ILazyContentProvider(){
+
+ IJavaStackFrame[] stack=null;
+
+ @Override
+ public void updateElement(int index) {
+ if(stack!=null) {
+ if(index>=0 && index<stack.length) {
+ viewer.replace(stack[index], index);
+ }
+ }
+
+ }
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void inputChanged(Viewer arg0, Object oldObj, Object newObj) {
+ if(newObj instanceof IJavaStack) {
+ IJavaStack s=(IJavaStack) newObj;
+ IJavaStackFrame[] frames=s.getStack();
+ if(frames!=null) {
+ stack=frames;
+ viewer.setItemCount(stack.length);
+ }
+
+ return;
+ }
+
+ stack=null;
+ viewer.setItemCount(0);
+
+ }});
+
+
+
+
+ return viewer;
+ }
+private static TableViewer buildThreadViewerTable(SashForm sashForm,HProfView view, final TableViewer stackviewer) {
+ TableViewer viewer=new TableViewer(sashForm,SWT.BORDER | SWT.VIRTUAL);
+ final Table table=viewer.getTable();
+
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ TableColumn column=new TableColumn(table,SWT.LEFT,0);
+ column.setText("Active");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.LEFT,1);
+ column.setText("Thread Serial");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.LEFT,2);
+ column.setText("Thread Obj ID");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.LEFT,3);
+ column.setText("Stack Serial");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.LEFT,4);
+ column.setText("Name");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.LEFT,5);
+ column.setText("Group Name");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.LEFT,6);
+ column.setText("Parent Group Name");
+ column.setWidth(100);
+
+
+ table.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ TableItem[] selection = table.getSelection();
+ IJavaThread selectedThread=(IJavaThread) selection[0].getData();
+ IJavaStack stack=selectedThread.getStack();
+ stackviewer.setInput(stack);
+
+ }
+ });
+
+
+
+
+
+
+ viewer.setContentProvider(new AbstractHProfLazyContentProvider(viewer,view){
+
+ @Override
+ public void updateEntry(TableViewer tableViewer, HProfView dumpViewer,
+ int index) {
+ IJavaThread thread = dumpViewer.getThread(index);
+ tableViewer.replace(thread, index);
+
+ }
+ @Override
+ public int getTableSize(HProfView view) {
+ return view.getThreadCount();
+ }});
+
+
+
+
+ viewer.setLabelProvider(new AbstractHProfViewLabelProvider(){
+
+
+
+ @Override
+ public String getColumnText(Object obj, int column) {
+ if(obj instanceof IJavaThread==false) return null;
+ IJavaThread thread=(IJavaThread) obj;
+ switch(column) {
+ case 0: return ""+thread.isActive();
+ case 1: return ""+thread.getThreadSerialNumber();
+ case 2: return HProfRecordFormatter.toHex(thread.getThreadObjectID());
+ case 3: return ""+thread.getStackTraceSerialNumber();
+ case 4: return thread.getThreadName();
+ case 5: return thread.getThreadGroupName();
+ case 6: return thread.getThreadGroupParentName();
+ default: return "";
+ }
+ }
+
+ });
+
+
+
+ viewer.setInput(view);
+
+ return viewer;
+
+
+}
+
+
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/RecordsViewerFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/RecordsViewerFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/RecordsViewerFactory.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/RecordsViewerFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.ui.factory;
+
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.datalayer.IHProfRecord;
+import org.apache.kato.hprof.ui.HProfRecordHandle;
+import org.apache.kato.hprof.ui.provider.AbstractHProfLazyContentProvider;
+import org.apache.kato.hprof.ui.provider.AbstractHProfViewLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+
+public class RecordsViewerFactory {
+
+ public static TableViewer createViewer(Composite parent,final HProfView view) {
+
+ TableViewer viewer=new TableViewer(parent,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL);
+ Table table = viewer.getTable();
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+
+ TableColumn column=new TableColumn(table,SWT.RIGHT,0);
+ column.setText("#");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.LEFT,1);
+ column.setText("TAG");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.LEFT,2);
+ column.setText("Name");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.RIGHT,3);
+ column.setText("Location");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.RIGHT,4);
+ column.setText("Length");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.LEFT | SWT.WRAP,5);
+ column.setText("Data");
+ column.setWidth(500);
+
+
+ viewer.setContentProvider(new AbstractHProfLazyContentProvider(viewer,view){
+
+ @Override
+ public int getTableSize(HProfView dumpViewer) {
+ return dumpViewer.getFile().getRecordCount();
+ }
+
+ @Override
+ public void updateEntry(TableViewer tableViewer,
+ HProfView dumpViewer, int index) {
+
+ tableViewer.replace(new HProfRecordHandle(index,dumpViewer), index);
+
+
+ }});
+
+ viewer.setLabelProvider(new AbstractHProfViewLabelProvider(){
+
+ @Override
+ public String getColumnText(Object element, int index) {
+ if(element instanceof HProfRecordHandle ==false) return null;
+ HProfRecordHandle handle=(HProfRecordHandle) element;
+ IHProfRecord record=handle.getRecord();
+
+ switch(index) {
+ case 0 : return ""+handle.recordNumber;
+ case 1 : return HProfRecordFormatter.toHex(record.getTag());
+ case 2 : return HProfRecordFormatter.getTagName(record);
+ case 3 : return HProfRecordFormatter.toHex(handle.getRecordLocation());
+ case 4 : return HProfRecordFormatter.toHex(record.getDataLength()+9);
+ case 5 :
+ byte[] bytes=record.getData();
+ return HProfRecordFormatter.toHex(bytes,0,64);
+ }
+
+ return null;
+ }});
+
+ return viewer;
+ }
+
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/StackTraceViewerFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/StackTraceViewerFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/StackTraceViewerFactory.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/StackTraceViewerFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * 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.ui.factory;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.datalayer.IJavaStackFrameHProfRecord;
+import org.apache.kato.hprof.datalayer.IJavaStackTraceHProfRecord;
+import org.apache.kato.hprof.ui.provider.AbstractHProfLazyContentProvider;
+import org.apache.kato.hprof.ui.provider.AbstractHProfViewLabelProvider;
+import org.eclipse.jface.viewers.ILazyContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class StackTraceViewerFactory {
+
+
+ public static Composite createViewer(Composite parent,HProfView view) {
+ // Create the SashForm
+ Composite sash = new Composite(parent, SWT.NONE);
+ sash.setLayout(new FillLayout());
+ sash.setLayoutData(new GridData(GridData.FILL_BOTH));
+ SashForm sashForm = new SashForm(sash, SWT.VERTICAL);
+
+ // Change the width of the sashes
+ sashForm.SASH_WIDTH = 20;
+
+
+ TableViewer v=buildStackTraceFrameTable(sashForm,view);
+
+ buildStackTraceTable(sashForm,v,view);
+
+ return sash;
+
+
+ }
+
+ private static TableViewer buildStackTraceFrameTable(SashForm sashForm,final HProfView view) {
+ final TableViewer viewer=new TableViewer(sashForm,SWT.BORDER | SWT.VIRTUAL);
+ final Table stack = viewer.getTable();
+
+ stack.setLinesVisible(true);
+ stack.setHeaderVisible(true);
+
+
+ TableColumn column=new TableColumn(stack,SWT.LEFT,0);
+ column.setText("Frame ID");
+ column.setWidth(100);
+ column=new TableColumn(stack,SWT.LEFT,1);
+ column.setText("Method");
+ column.setWidth(100);
+ column=new TableColumn(stack,SWT.LEFT,2);
+ column.setText("Signature");
+ column.setWidth(100);
+ column=new TableColumn(stack,SWT.LEFT,3);
+ column.setText("Source File");
+ column.setWidth(100);
+ column=new TableColumn(stack,SWT.RIGHT,4);
+ column.setText("Class Serial No");
+ column.setWidth(100);
+ column=new TableColumn(stack,SWT.RIGHT,5);
+ column.setText("Line");
+ column.setWidth(100);
+
+
+ viewer.setLabelProvider(new AbstractHProfViewLabelProvider(){
+
+ @Override
+ public String getColumnText(Object obj, int index) {
+ IJavaStackFrameHProfRecord frame=(IJavaStackFrameHProfRecord) obj;
+ switch (index) {
+ case 0: return HProfRecordFormatter.toHex(frame.getStackFrameID());
+ case 1: return view.getName(frame.getMethodNameID());
+ case 2: return view.getName(frame.getMethodSignatureID());
+ case 3: return view.getName(frame.getSourceFileNameID());
+ case 4: return ""+frame.getClassSerialNumber();
+ case 5: return ""+frame.getLineNumber();
+ }
+ return null;
+ }} );
+
+ viewer.setContentProvider(new ILazyContentProvider(){
+
+ Long[] stack=null;
+
+ @Override
+ public void updateElement(int index) {
+ if(stack!=null) {
+ if(index>=0 && index<stack.length) {
+ viewer.replace(view.getStackFrameRecordFromID(stack[index]), index);
+ }
+ }
+
+ }
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void inputChanged(Viewer arg0, Object oldObj, Object newObj) {
+ if(newObj instanceof IJavaStackTraceHProfRecord) {
+
+
+ IJavaStackTraceHProfRecord s=(IJavaStackTraceHProfRecord) newObj;
+ List<Long> data=new LinkedList<Long>();
+ for(int i=0;i<s.getFrameCount();i++) {
+ data.add(s.getStackFrameID(i));
+ }
+
+ viewer.setItemCount(data.size());
+ stack=data.toArray(new Long[0]);
+ }
+
+
+
+ }});
+
+
+
+
+ return viewer;
+ }
+ private static void buildStackTraceTable(SashForm sashForm, final TableViewer detailViewer,HProfView view) {
+ TableViewer viewer=new TableViewer(sashForm,SWT.BORDER | SWT.VIRTUAL);
+ final Table table=viewer.getTable();
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+ TableColumn column=new TableColumn(table,SWT.RIGHT,0);
+ column.setText("Serial Number");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.RIGHT,1);
+ column.setText("Thread Serial Number");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.RIGHT,2);
+ column.setText("Frame Count");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.LEFT,3);
+ column.setText("Frames");
+ column.setWidth(500);
+
+
+ table.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ TableItem[] selection = table.getSelection();
+ Object o=selection[0].getData();
+ if(o instanceof IJavaStackTraceHProfRecord) {
+ IJavaStackTraceHProfRecord selectedThread=(IJavaStackTraceHProfRecord)o ;
+ detailViewer.setInput(selectedThread);
+ }
+ }
+ });
+
+
+
+ viewer.setContentProvider(new AbstractHProfLazyContentProvider(viewer,view){
+
+ @Override
+ public int getTableSize(HProfView dumpViewer) {
+
+ return dumpViewer.getStackTraceCount();
+ }
+
+ @Override
+ public void updateEntry(TableViewer tableViewer,
+ HProfView dumpViewer, int index) {
+
+ IJavaStackTraceHProfRecord rec=dumpViewer.getStackTraceRecord(index);
+ tableViewer.replace(rec, index);
+
+
+
+
+ }});
+
+ viewer.setLabelProvider(new AbstractHProfViewLabelProvider(){
+
+ @Override
+ public String getColumnText(Object obj, int index) {
+ IJavaStackTraceHProfRecord rec=(IJavaStackTraceHProfRecord) obj;
+ switch (index) {
+ case 0: return ""+rec.getSerialNumber();
+ case 1: return ""+rec.getThreadSerialNumber();
+ case 2: return ""+rec.getFrameCount();
+ case 3:
+ String frames="";
+ int frameCount=rec.getFrameCount();
+ if(frameCount>0) {
+ for(int i=0;i<frameCount;i++) {
+ frames=frames+HProfRecordFormatter.toHex(rec.getStackFrameID(i))+" ";
+ }
+ }
+ return frames;
+
+ }
+ return null;
+ }} );
+
+ viewer.setInput(view);
+ }
+
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/UTF8RecordsViewerFactory.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/UTF8RecordsViewerFactory.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/UTF8RecordsViewerFactory.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/factory/UTF8RecordsViewerFactory.java Thu May 7 14:50:21 2009
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.ui.factory;
+
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.ui.provider.AbstractHProfLazyContentProvider;
+import org.apache.kato.hprof.ui.provider.StringArrayLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class UTF8RecordsViewerFactory {
+
+
+ public static Composite createViewer(Composite parent,HProfView view) {
+ TableViewer viewer=new TableViewer(parent,SWT.BORDER | SWT.VIRTUAL);
+ Table table = viewer.getTable();
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+ TableColumn column=new TableColumn(table,SWT.LEFT,0);
+ column.setText("ID");
+ column.setWidth(100);
+
+ column=new TableColumn(table,SWT.RIGHT,1);
+ column.setText("Length");
+ column.setWidth(50);
+
+ column=new TableColumn(table,SWT.LEFT,2);
+ column.setText("Value");
+ column.setWidth(500);
+
+
+
+ viewer.setContentProvider(new AbstractHProfLazyContentProvider(viewer,view){
+
+ @Override
+ public void updateEntry(TableViewer tableViewer, HProfView dumpViewer,
+ int index) {
+ Long id = dumpViewer.getUTF8IDFromIndex(index);
+ String idFormat=HProfRecordFormatter.toHex(id);
+ int length=dumpViewer.getUTF8Length(id);
+ String value=dumpViewer.getUTF8String(id);
+ tableViewer.replace(new String[]{idFormat,""+length,value}, index);
+
+ }
+ @Override
+ public int getTableSize(HProfView view) {
+ return view.getUTF8Count();
+ }});
+
+ viewer.setLabelProvider(new StringArrayLabelProvider());
+ viewer.setInput(view);
+
+ return table;
+ }
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/popup/actions/NewAction.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/popup/actions/NewAction.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/popup/actions/NewAction.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/popup/actions/NewAction.java Thu May 7 14:50:21 2009
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.ui.popup.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class NewAction implements IObjectActionDelegate {
+
+ private Shell shell;
+
+ /**
+ * Constructor for Action1.
+ */
+ public NewAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ shell = targetPart.getSite().getShell();
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ MessageDialog.openInformation(
+ shell,
+ "Hprof binary format reader Ui Plug-in",
+ "New Action was executed.");
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/propertysource/GCClassHeapDumpRecordPropertySource.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/propertysource/GCClassHeapDumpRecordPropertySource.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/propertysource/GCClassHeapDumpRecordPropertySource.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/propertysource/GCClassHeapDumpRecordPropertySource.java Thu May 7 14:50:21 2009
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * 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.ui.propertysource;
+
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.datalayer.ConstantPoolEntry;
+import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
+import org.apache.kato.hprof.datalayer.HProfFile.GCClassHeapDumpRecord;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+public class GCClassHeapDumpRecordPropertySource implements IPropertySource {
+
+ public class ConstantPoolEntryPropertySource implements IPropertySource{
+
+
+ private static final String CP_INDEX="cp.index";
+ private static final String CP_TYPE="cp.type";
+ private static final String CP_DATA="cp.data";
+
+ private PropertyDescriptor[] recordDescriptors = new PropertyDescriptor[] {
+
+ new PropertyDescriptor(CP_INDEX,"Index"),
+ new PropertyDescriptor(CP_TYPE,"Type"),
+ new PropertyDescriptor(CP_DATA,"Data")
+
+
+ };
+
+
+
+ private ConstantPoolEntry cpe=null;
+
+ public ConstantPoolEntryPropertySource(ConstantPoolEntry cpe) {
+ this.cpe=cpe;
+ }
+
+ @Override
+ public Object getEditableValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+
+ return recordDescriptors;
+ }
+
+ @Override
+ public Object getPropertyValue(Object id) {
+
+ if(id==CP_INDEX) return cpe.cpIndex;
+ if(id==CP_TYPE) return cpe.type;
+ if(id==CP_DATA) return "todo";
+
+ return null;
+ }
+
+ @Override
+ public boolean isPropertySet(Object id) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void resetPropertyValue(Object id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setPropertyValue(Object id, Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ public static final String LOCATION="location";
+ private static final String CLASS_OBJ_ID="class.obj.id";
+ private static final String STACK_TRACE_SERIAL_NO="stack.trace.serial.no";
+ private static final String SUPER_CLASS_OBJ_ID="super.class.obj.id";
+ private static final String CONSTANT_POOL_SIZE="constant.pool.size";
+ private static final String CONSTANT_POOL="constant.pool";
+ private ConstantPoolEntryPropertySource cpEntry=null;
+
+ private static PropertyDescriptor[] recordDescriptors;
+ static {
+ recordDescriptors = new PropertyDescriptor[] {
+
+ new PropertyDescriptor(LOCATION,"File Offset"),
+ new PropertyDescriptor(CLASS_OBJ_ID,"Class Object ID"),
+ new PropertyDescriptor(STACK_TRACE_SERIAL_NO,"Stack Trace Serial No"),
+ new PropertyDescriptor(SUPER_CLASS_OBJ_ID,"Superclass Object ID"),
+ new PropertyDescriptor(CONSTANT_POOL_SIZE,"No of entries in constant pool"),
+ new PropertyDescriptor(CONSTANT_POOL,"Constant Pool")
+
+ };
+ }
+
+
+ private GCClassHeapDumpRecord record=null;
+ private IHeapDumpHProfRecord heap=null;
+ private int recordNo=0;
+
+
+ public GCClassHeapDumpRecordPropertySource(IHeapDumpHProfRecord dumpRecord,GCClassHeapDumpRecord rec,int recordNo) {
+ this.record=rec;
+ this.recordNo=recordNo;
+ this.heap=dumpRecord;
+ }
+
+ @Override
+ public Object getEditableValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+
+ return recordDescriptors;
+ }
+
+ @Override
+ public Object getPropertyValue(Object id) {
+ if (id.equals(LOCATION)) {
+ long location=heap.getSubRecordLocation(recordNo);
+ return toHex(location);
+
+ }
+ if (id.equals(CLASS_OBJ_ID)) {
+ return toHex(record.getID());
+ }
+ if(id.equals(STACK_TRACE_SERIAL_NO)) {
+ return record.getStackTraceNumber();
+ }
+ if(id.equals(SUPER_CLASS_OBJ_ID)) {
+ return toHex(record.getSuperClassObjectID());
+ }
+ if(id.equals(CONSTANT_POOL)) {
+
+ return convert(record.getConstantPool());
+ }
+ if(id.equals(CONSTANT_POOL_SIZE)) {
+ return record.getConstantPoolSize();
+ }
+ return null;
+ }
+
+ private Object convert(ConstantPoolEntry[] constantPool) {
+ ConstantPoolEntryPropertySource[] data=new ConstantPoolEntryPropertySource[constantPool.length];
+ for(int i=0;i<data.length;i++) {
+ data[i]=new ConstantPoolEntryPropertySource(constantPool[i]);
+ }
+ return data;
+ }
+
+ private static String toHex(long v) {
+ return HProfRecordFormatter.toHex(v);
+ }
+
+ @Override
+ public boolean isPropertySet(Object id) {
+
+ return false;
+ }
+
+ @Override
+ public void resetPropertyValue(Object id) {
+
+
+ }
+
+ @Override
+ public void setPropertyValue(Object id, Object value) {
+
+
+ }
+
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfLazyContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfLazyContentProvider.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfLazyContentProvider.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfLazyContentProvider.java Thu May 7 14:50:21 2009
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.ui.provider;
+
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.IJavaThread;
+import org.eclipse.jface.viewers.ILazyContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+public abstract class AbstractHProfLazyContentProvider implements ILazyContentProvider {
+ private TableViewer tableViewer = null;
+ protected HProfView dumpViewer = null;
+
+ public AbstractHProfLazyContentProvider(TableViewer viewer,HProfView dumpView) {
+ this.tableViewer=viewer;
+ this.dumpViewer=dumpView;
+ }
+ @Override
+ public void updateElement(int index) {
+ if (tableViewer != null) {
+
+ updateEntry(tableViewer, dumpViewer, index);
+
+ }
+
+ }
+
+
+
+ public abstract void updateEntry(TableViewer tableViewer, HProfView dumpViewer,
+ int index);
+
+
+
+
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldObject, Object newObject) {
+
+ if (newObject instanceof HProfView) {
+ HProfView view = (HProfView) newObject;
+ tableViewer = (TableViewer) viewer;
+ int tableSize = getTableSize(dumpViewer);
+ tableViewer.setItemCount(tableSize);
+
+
+ }
+
+ }
+
+ public abstract int getTableSize(HProfView dumpViewer);
+}
\ No newline at end of file
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfViewLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfViewLabelProvider.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfViewLabelProvider.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/AbstractHProfViewLabelProvider.java Thu May 7 14:50:21 2009
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.ui.provider;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public abstract class AbstractHProfViewLabelProvider implements ITableLabelProvider{
+
+ @Override
+ public Image getColumnImage(Object arg0, int arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+ @Override
+ public void addListener(ILabelProviderListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isLabelProperty(Object arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/HeapDumpRecordLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/HeapDumpRecordLabelProvider.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/HeapDumpRecordLabelProvider.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/HeapDumpRecordLabelProvider.java Thu May 7 14:50:21 2009
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.ui.provider;
+
+import org.apache.kato.hprof.HProfRecordFormatter;
+import org.apache.kato.hprof.HProfView;
+import org.apache.kato.hprof.datalayer.IHProfRecord;
+import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
+import org.apache.kato.hprof.ui.HProfSubRecordHandle;
+import org.apache.kato.hprof.ui.factory.HProfRecordPropertySourceFactory;
+import org.apache.kato.hprof.ui.factory.HeapDumpsRecordViewerFactory;
+import org.apache.kato.hprof.ui.propertysource.GCClassHeapDumpRecordPropertySource;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+public class HeapDumpRecordLabelProvider implements
+ ITableLabelProvider {
+
+ private HProfView view=null;
+ public HeapDumpRecordLabelProvider(HProfView view) {
+ this.view=view;
+ }
+
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int index) {
+ if(element==null) return null;
+ HProfSubRecordHandle handle=(HProfSubRecordHandle) element;
+ IHProfRecord record=handle.getRecord();
+ if(record==null) {
+ return null;
+ }
+
+
+ switch(index) {
+ case 0: return ""+handle.recordNumber;
+ case 1:
+ IHeapDumpHProfRecord heapRecord=view.getHeapRecord();
+ if(heapRecord==null) return null;
+ IHProfRecord subRecord=heapRecord.getSubRecord(handle.recordNumber);
+ if(subRecord==null) return null;
+ long location=heapRecord.getSubRecordLocation(handle.recordNumber);
+
+ return ""+HProfRecordFormatter.toHex(location);
+
+ case 2: return ""+HProfRecordFormatter.toHex(record.getDataLength());
+ case 3: return record.getClass().getName();
+ case 4: return HProfRecordFormatter.toHex(record.getData(), 0, 50);
+ default: return null;
+ }
+
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+}
\ No newline at end of file
Added: incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/StringArrayLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/StringArrayLabelProvider.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/StringArrayLabelProvider.java (added)
+++ incubator/kato/trunk/HprofBinaryReaderPOCUI/src/org/apache/kato/hprof/ui/provider/StringArrayLabelProvider.java Thu May 7 14:50:21 2009
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.ui.provider;
+
+public class StringArrayLabelProvider extends AbstractHProfViewLabelProvider {
+ @Override
+ public String getColumnText(Object obj, int column) {
+ if(obj instanceof String[]==false) return null;
+ String[] data =(String[]) obj;
+ if(data.length==0) return "";
+ if(column>=data.length) return "";
+ return data[column];
+
+ }
+}
\ No newline at end of file
Added: incubator/kato/trunk/KatoHProfAdapterPOC/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/.settings/org.eclipse.jdt.core.prefs?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/.settings/org.eclipse.jdt.core.prefs (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/.settings/org.eclipse.jdt.core.prefs Thu May 7 14:50:21 2009
@@ -0,0 +1,12 @@
+#Mon Mar 16 14:47:57 GMT 2009
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
Added: incubator/kato/trunk/KatoHProfAdapterPOC/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/META-INF/MANIFEST.MF?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/META-INF/MANIFEST.MF (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/META-INF/MANIFEST.MF Thu May 7 14:50:21 2009
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: DTFJHProfAdapter
+Bundle-SymbolicName: KatoHProfAdapterPOC
+Bundle-Version: 1.0.0
+Require-Bundle: HprofBinaryReaderPOC;bundle-version="1.0.0",
+ org.junit
Added: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/CorruptDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/CorruptDataImpl.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/CorruptDataImpl.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/CorruptDataImpl.java Thu May 7 14:50:21 2009
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.image;
+
+import org.apache.kato.image.CorruptData;
+import org.apache.kato.image.ImagePointer;
+
+/**
+ * Our implementation of the CorruptData interface.
+ *
+ */
+public class CorruptDataImpl implements CorruptData {
+ private ImagePointer address;
+ private String message;
+
+ public CorruptDataImpl(ImagePointer address, String message) {
+ this.address = address;
+ this.message = message;
+ }
+
+ public CorruptDataImpl(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public ImagePointer getAddress() {
+ return address;
+ }
+
+ /**
+ * Return string representing this corrupt data like so:
+ * "Corrupt Data: [message]"
+ * or
+ * "Corrupt Data: @ 0x[address] [message]".
+ */
+ @Override
+ public String toString() {
+ if (address == null) {
+ return "CorruptData: "+message;
+ } else {
+ return "CorruptData: @ 0x" +
+ Long.toHexString(address.getAddress())+" "+message;
+ }
+ }
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java Thu May 7 14:50:21 2009
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.image;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.kato.image.ImageAddressSpace;
+import org.apache.kato.image.ImagePointer;
+import org.apache.kato.image.ImageProcess;
+
+final class ImageAddressSpaceImpl implements ImageAddressSpace {
+
+ /**
+ *
+ */
+ private final ImageImpl imageImpl;
+ private ImageProcess currentProcess=null;
+
+ /**รณ
+ * @param imageImpl
+ */
+ ImageAddressSpaceImpl(ImageImpl imageImpl) {
+ this.imageImpl = imageImpl;
+ currentProcess=new ImageProcessImpl(this.imageImpl);
+ }
+
+
+
+ @Override
+ public ImageProcess getCurrentProcess() {
+
+ return currentProcess;
+ }
+
+ @Override
+ public Iterator getImageSections() {
+
+ List l=new LinkedList();
+ return l.iterator();
+ }
+
+ @Override
+ public ImagePointer getPointer(long address) {
+ return new ImagePointerImpl(address);
+ }
+
+ @Override
+ public Iterator getProcesses() {
+ List l=new LinkedList();
+ l.add(currentProcess);
+ return l.iterator();
+ }
+}
\ No newline at end of file
Added: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageFactoryImpl.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageFactoryImpl.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageFactoryImpl.java Thu May 7 14:50:21 2009
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.image;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.kato.hprof.datalayer.HProfFactory;
+import org.apache.kato.hprof.datalayer.HProfFile;
+import org.apache.kato.image.Image;
+import org.apache.kato.image.ImageFactory;
+
+public class ImageFactoryImpl implements ImageFactory{
+
+ @Override
+ public int getDTFJMajorVersion() {
+
+ return 1;
+ }
+
+ @Override
+ public int getDTFJMinorVersion() {
+
+ return 3;
+ }
+
+ @Override
+ public int getDTFJModificationLevel() {
+
+ return 0;
+ }
+
+ @Override
+ public Image getImage(File imageFile) throws IOException {
+
+ return getImage(imageFile,null);
+ }
+
+ @Override
+ public Image getImage(File imageFile, File metadata) throws IOException {
+
+ if(imageFile==null) throw new IllegalArgumentException("image file is null");
+ HProfFile hprofFile=HProfFactory.createReader(imageFile);
+
+ //hprofFile.open();
+ ImageImpl impl=new ImageImpl(hprofFile);
+
+ return impl;
+ }
+
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java Thu May 7 14:50:21 2009
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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.image;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.kato.hprof.datalayer.HProfFile;
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.Image;
+
+public class ImageImpl implements Image {
+
+ HProfFile file=null;
+
+
+ public ImageImpl(HProfFile file) {
+ if(file==null) throw new IllegalArgumentException("file is null");
+ this.file=file;
+
+ }
+ @Override
+ public Iterator getAddressSpaces() {
+ List list=new LinkedList();
+ list.add(new ImageAddressSpaceImpl(this));
+
+ return list.iterator();
+ }
+
+ @Override
+ public long getCreationTime() throws DataUnavailable {
+
+ return file.getTimeStamp();
+
+ }
+
+ @Override
+ public String getHostName() throws DataUnavailable, CorruptDataException {
+
+ throw new DataUnavailable();
+
+ }
+
+ @Override
+ public Iterator getIPAddresses() throws DataUnavailable {
+
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public long getInstalledMemory() throws DataUnavailable {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public int getProcessorCount() throws DataUnavailable {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public String getProcessorSubType() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public String getProcessorType() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public String getSystemSubType() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public String getSystemType() throws DataUnavailable, CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java Thu May 7 14:50:21 2009
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * 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.image;
+
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImageAddressSpace;
+import org.apache.kato.image.ImagePointer;
+import org.apache.kato.image.MemoryAccessException;
+
+public class ImagePointerImpl implements ImagePointer {
+
+ private long address=0;
+
+ public ImagePointerImpl(long address) {
+ this.address=address;
+ }
+ @Override
+ public ImagePointer add(long offset) {
+
+ return new ImagePointerImpl(address+offset);
+ }
+
+ @Override
+ public long getAddress() {
+
+ return address;
+ }
+
+ @Override
+ public ImageAddressSpace getAddressSpace() {
+
+ return null;
+ }
+
+ @Override
+ public byte getByteAt(long index) throws MemoryAccessException,
+ CorruptDataException {
+
+ throwError();
+ return 0;
+ }
+
+ @Override
+ public double getDoubleAt(long index) throws MemoryAccessException,
+ CorruptDataException {
+ throwError();
+ return 0;
+ }
+
+ @Override
+ public float getFloatAt(long index) throws MemoryAccessException,
+ CorruptDataException {
+ throwError();
+ return 0;
+ }
+
+ @Override
+ public int getIntAt(long index) throws MemoryAccessException,
+ CorruptDataException {
+ throwError();
+ return 0;
+ }
+
+ @Override
+ public long getLongAt(long index) throws MemoryAccessException,
+ CorruptDataException {
+ throwError();
+ return 0;
+ }
+
+ @Override
+ public ImagePointer getPointerAt(long index) throws MemoryAccessException,
+ CorruptDataException {
+
+ return new ImagePointerImpl(index);
+ }
+
+ @Override
+ public short getShortAt(long index) throws MemoryAccessException,
+ CorruptDataException {
+ throwError();
+ return 0;
+ }
+
+ @Override
+ public boolean isExecutable() throws DataUnavailable {
+ throw new DataUnavailable();
+
+ }
+
+ @Override
+ public boolean isReadOnly() throws DataUnavailable {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public boolean isShared() throws DataUnavailable {
+ throw new DataUnavailable();
+ }
+
+ private void throwError() throws MemoryAccessException {
+ throw new MemoryAccessException(this,"memory access invalid with hprof dump");
+ }
+
+}
Added: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java Thu May 7 14:50:21 2009
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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.image;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.kato.hprof.java.JavaRuntimeImpl;
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImageModule;
+import org.apache.kato.image.ImageProcess;
+import org.apache.kato.image.ImageThread;
+
+class ImageProcessImpl implements ImageProcess {
+ /**
+ *
+ */
+ private final ImageImpl imageImpl;
+ private JavaRuntimeImpl javaRuntime=null;
+ /**
+ * @param imageImpl
+ */
+ ImageProcessImpl(ImageImpl imageImpl) {
+ this.imageImpl = imageImpl;
+ }
+
+ @Override
+ public String getCommandLine() throws DataUnavailable,
+ CorruptDataException {
+
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public ImageThread getCurrentThread() throws CorruptDataException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Properties getEnvironment() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public ImageModule getExecutable() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public String getID() throws DataUnavailable, CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public Iterator getLibraries() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public int getPointerSize() {
+ return this.imageImpl.file.getIdentifierSize();
+
+ }
+
+ @Override
+ public Iterator getRuntimes() {
+
+ if(javaRuntime==null) {
+ javaRuntime=new JavaRuntimeImpl(this.imageImpl.file);
+ }
+ List list=new LinkedList();
+ list.add(javaRuntime);
+ return list.iterator();
+ }
+
+ @Override
+ public String getSignalName() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public int getSignalNumber() throws DataUnavailable,
+ CorruptDataException {
+ throw new DataUnavailable();
+ }
+
+ @Override
+ public Iterator getThreads() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
\ No newline at end of file
Added: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java?rev=772669&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java (added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java Thu May 7 14:50:21 2009
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.java;
+
+import java.util.Collection;
+
+import org.apache.kato.java.JavaHeap;
+import org.apache.kato.java.JavaObject;
+
+/**
+ * Source of objects and everything to do with them,
+ * such as classloaders and javaclasses.
+ *
+ *
+ */
+public interface IJavaHeapInternal extends JavaHeap {
+
+ abstract JavaObject getObjectByID(Long element);
+
+ abstract JavaClassImpl getJavaClassByID(long arrayClassObjectID);
+
+ abstract JavaClassImpl getPrimitiveArrayClass(short elementType);
+
+ abstract String getUTF8StringByID(long fieldNameID);
+
+ abstract JavaClassLoaderImpl getJavaClassLoaderByID(long classLoaderObjectID);
+
+ abstract JavaPrimitiveClassImpl getPrimitiveClass(int l);
+
+ Collection<JavaClassLoaderImpl> getJavaClassLoaders();
+
+
+}