[jboss-cvs] JBoss Profiler SVN: r558 - in branches/JBossProfiler2: src/main/org/jboss/profiler/jvmti and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 12 00:33:54 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-08-12 00:33:52 -0400 (Wed, 12 Aug 2009)
New Revision: 558
Added:
branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/TestClass.java
Modified:
branches/JBossProfiler2/.classpath
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java
branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java
Log:
tweaks
Modified: branches/JBossProfiler2/.classpath
===================================================================
--- branches/JBossProfiler2/.classpath 2009-08-11 21:05:43 UTC (rev 557)
+++ branches/JBossProfiler2/.classpath 2009-08-12 04:33:52 UTC (rev 558)
@@ -21,5 +21,6 @@
<classpathentry kind="lib" path="lib/richfaces-ui.jar"/>
<classpathentry kind="lib" path="lib/servlet.jar"/>
<classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/>
+ <classpathentry kind="var" path="ANT_HOME"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java 2009-08-11 21:05:43 UTC (rev 557)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java 2009-08-12 04:33:52 UTC (rev 558)
@@ -80,6 +80,23 @@
public native void stopMeasure();
/** returns the first class found with a given name */
+ public Class<?>[] getAllClassMachingName(final String className)
+ {
+ Class<?> classes[] = getLoadedClasses();
+
+ ArrayList<Class<?>> foundClasses = new ArrayList<Class<?>>();
+
+ for (Class<?> clazz : classes)
+ {
+ if (clazz.getName().equals(className))
+ {
+ foundClasses.add(clazz);
+ }
+ }
+
+ return foundClasses.toArray(new Class<?>[foundClasses.size()]);
+ }
+
public Class<?> getClassByName(final String className)
{
Class<?> classes[] = getLoadedClasses();
@@ -624,16 +641,7 @@
final long method,
final byte referenceType)
{
- if (count == 0)
- {
- System.out.println("started receiving references");
- }
- count++;
- if (count % 1000 == 0)
- {
- System.out.println(count + " references received");
- }
- ReferenceDataPoint dataPoint = new ReferenceDataPoint(referenceHolder,
+ ReferenceDataPoint dataPoint = new ReferenceDataPoint(referenceHolder,
referencedObject,
classTag,
index,
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java 2009-08-11 21:05:43 UTC (rev 557)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/InstancesHandler.java 2009-08-12 04:33:52 UTC (rev 558)
@@ -45,7 +45,7 @@
// Constants -----------------------------------------------------
- private static final int NUMBER_OF_ELEMENTS = 300;
+ private static final int NUMBER_OF_ELEMENTS = 50;
// Attributes ----------------------------------------------------
@@ -101,7 +101,18 @@
{
index = server.createIndex();
}
+
+ Class<?>[] clazzes = jvmti.getAllClassMachingName(classToPrint);
+
+ output.println("Classes:<br/>");
+ for (Class<?> clazzElement : clazzes)
+ {
+ long classTagId = jvmti.getTagOnObject((Object)clazzElement);
+ output.println("<a href='./reference?obj0=" +classTagId + "'>" + clazzElement.getCanonicalName() + " with ClassLoader = (" + clazzElement.getClassLoader() + ")</a><br>");
+ }
+
+ output.println("<br/><br/> Instances:<br/><br/>");
Class clazz = jvmti.getClassByName(classToPrint);
if (clazz == null)
@@ -124,9 +135,10 @@
int elementFound = 0;
for (ReferenceDataPoint point : references)
{
+ System.out.println("Reference = " + JVMTITypes.toString(point.getReferenceType()));
if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_INSTANCE)
{
- if (elementFound++ > elementNR)
+ if (elementFound++ >= elementNR)
{
if (point.getReferenceHolder() != 0)
{
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java 2009-08-11 21:05:43 UTC (rev 557)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/ReferenceHandler.java 2009-08-12 04:33:52 UTC (rev 558)
@@ -195,6 +195,23 @@
output.println("<br> Reference inside a method - " + className + "::" + methodName);
}
}
+ else if (point.getReferenceType() == JVMTITypes.JVMTI_REFERENCE_STATIC_FIELD)
+ {
+ Class<?> clazz = (Class<?>)referenceHolder;
+ Field field = jvmti.getObjectField(clazz, (int)point.getIndex());
+ String fieldName = null;
+ if (field == null)
+ {
+ fieldName = "UndefinedField@" + referenceHolder;
+ }
+ else
+ {
+ fieldName = field.toString();
+ }
+ output.println("<a href='" + newURL + "'>Static field reference:" + fieldName + "</a>");
+ }
+
+
}
}
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java 2009-08-11 21:05:43 UTC (rev 557)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/memoryweb/RootHandler.java 2009-08-12 04:33:52 UTC (rev 558)
@@ -22,14 +22,18 @@
package org.jboss.profiler.jvmti.memoryweb;
+import java.io.CharArrayWriter;
import java.io.PrintStream;
+import java.io.PrintWriter;
import java.net.URLEncoder;
+import java.util.Iterator;
import java.util.Map;
import java.util.TreeSet;
import com.sun.net.httpserver.HttpExchange;
import org.jboss.profiler.jvmti.InventoryDataPoint;
+import org.jboss.profiler.jvmti.JVMTIInterface;
/**
* A RootHandler
@@ -62,7 +66,6 @@
/* (non-Javadoc)
* @see org.jboss.profiler.jvmti.webembed.AbstractHandler#handle(com.sun.net.httpserver.HttpExchange, java.util.Map)
*/
- @Override
public synchronized void handle(final HttpExchange exchange,
final Map<String, String> queryAttributes,
final PrintStream output) throws Exception
@@ -72,13 +75,19 @@
Map<Class<?>, InventoryDataPoint> inventory = server.getJvmti().produceInventory();
TreeSet<InventoryDataPoint> points = new TreeSet<InventoryDataPoint>(inventory.values());
+ Iterator iterDataPoints = points.iterator();
output.println("<table>");
output.println("<tr><td>Name</td><td>#Instances</td><td>#Bytes</td></tr>");
+
+
+
+
- for (InventoryDataPoint point : points)
+ while (iterDataPoints.hasNext())
{
+ InventoryDataPoint point = (InventoryDataPoint)iterDataPoints.next();
output.println("<tr><td><a href='./instances?class=" + URLEncoder.encode(point.getClazz().getName()) +
"'>" +
point.getClazz().getName() +
@@ -92,6 +101,18 @@
output.println("</table>");
}
+
+
+ public synchronized void handle2(final HttpExchange exchange,
+ final Map<String, String> queryAttributes,
+ final PrintStream output) throws Exception
+ {
+ server.clearIndex();
+
+ output.println(server.getJvmti().inventoryReport(true));
+
+ }
+
// Package protected ---------------------------------------------
Modified: branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java
===================================================================
--- branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java 2009-08-11 21:05:43 UTC (rev 557)
+++ branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/JVMTIWebTestManual.java 2009-08-12 04:33:52 UTC (rev 558)
@@ -20,7 +20,6 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-
package org.jboss.profiler.test.jvmti;
import java.net.InetSocketAddress;
@@ -48,10 +47,12 @@
*/
public class JVMTIWebTestManual
{
- String str2[] = null;
- String strroot;
-
-
+ TestClass str2[] = null;
+
+ TestClass strroot;
+
+ static TestClass staticField;
+
public static void main(String arg[])
{
try
@@ -64,31 +65,32 @@
e.printStackTrace();
}
}
-
+
public void testWeb() throws Exception
{
- String str[] = new String[100];
-
- for (int i = 0 ; i < 100; i++)
- {
- str[i] = "value " + i;
- }
-
-
+ TestClass str[] = new TestClass[1];
+
+ str[0] = new TestClass();
+
str2 = str;
-
- String strroot2 = str[0];
+
+ TestClass strroot2 = str[0];
strroot = str[0];
-
+
+ staticField = str[0];
+
JVMTIInterface jvmti = new JVMTIInterface();
+ System.out.println(jvmti.inventoryReport());
+
CountDownLatch latch = new CountDownLatch(1);
jvmti.startMemoryProfiler(new InetSocketAddress(3232), latch);
+
- System.out.println("Value = " + str + " 5 = " + str[5] + " strroot = " + strroot2);
+ latch.await();
- latch.await();
+ System.out.println("strroot = " + strroot2);
}
}
Added: branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/TestClass.java
===================================================================
--- branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/TestClass.java (rev 0)
+++ branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/TestClass.java 2009-08-12 04:33:52 UTC (rev 558)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.profiler.test.jvmti;
+
+/**
+ * A DumbClass
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class TestClass
+{
+
+ long a = 1;
+ long a2 = 1;
+ long a3 = 1;
+ long a4 = 1;
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list