[jboss-cvs] JBoss Profiler SVN: r482 - in branches/JBossProfiler2: src/main/org/jboss/profiler/agent and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 20 16:50:52 EDT 2008
Author: jesper.pedersen
Date: 2008-10-20 16:50:52 -0400 (Mon, 20 Oct 2008)
New Revision: 482
Modified:
branches/JBossProfiler2/doc/README.txt
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/AbstractTransformer.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThread.java
branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThreadImpl.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java
branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java
branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java
branches/JBossProfiler2/src/main/org/jboss/profiler/ui/ThreadHotspotBean.java
branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/Test.java
Log:
Make it compile...
Modified: branches/JBossProfiler2/doc/README.txt
===================================================================
--- branches/JBossProfiler2/doc/README.txt 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/doc/README.txt 2008-10-20 20:50:52 UTC (rev 482)
@@ -76,6 +76,7 @@
diff : Compare snapshots
add : Add classes (public|package|protected|private)
remove : Remove classes
+ list : List classes
Host defaults to 'localhost'.
Port defaults to '5400'.
@@ -100,8 +101,8 @@
Client diff oldsnapshot.jps newsnapshot.jps
Client add org.jboss.profiler.test.* public
Client remove org.jboss.profiler.test.*
+Client list
-
jboss-profiler.properties:
--------------------------
enable Enable / disable profiler
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/AbstractTransformer.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/AbstractTransformer.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/AbstractTransformer.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -50,7 +50,7 @@
byte[] classfileBuffer) throws IllegalClassFormatException {
byte[] result = null;
-
+
if (Agent.isEnabled() && Agent.accept(className)) {
try {
if (Agent.isRepository() && !ClassRepository.exists(className, loader)) {
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Agent.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -755,6 +755,26 @@
}
/**
+ * List classes
+ * @return The classes
+ */
+ public static String[] listClasses() {
+ String[] result = new String[includeList.size()];
+ for (int i = 0; i < includeList.size(); i++) {
+ String s = includeList.get(i);
+
+ if (s.endsWith("/")) {
+ s = s.substring(0, s.length() - 1) + ".*";
+ }
+
+ s = s.replace('/', '.');
+
+ result[i] = s;
+ }
+ return result;
+ }
+
+ /**
* Redefine
* @param clz The classes
* @param instrument Should the classes be instrumented ?
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/JavassistTransformer.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -32,6 +32,9 @@
import javassist.CtConstructor;
import javassist.CtMethod;
import javassist.Modifier;
+import javassist.CodeConverter;
+import javassist.expr.ExprEditor;
+import javassist.expr.MethodCall;
/**
* Implements the Javssist based transformer
@@ -47,6 +50,8 @@
*/
public JavassistTransformer() {
pool = ClassPool.getDefault();
+
+ setup();
}
/**
@@ -184,4 +189,53 @@
java.lang.Thread#yield()
*/
}
+
+ /**
+ *
+ */
+ private void setup() {
+ try {
+ CtClass cProfiler = pool.get("org.jboss.profiler.agent.Profiler");
+ CtMethod mBeginWait = cProfiler.getDeclaredMethod("beginWait");
+ CtMethod mEndWait = cProfiler.getDeclaredMethod("endWait");
+
+ CtClass cThread = pool.get("java.lang.Thread");
+ CtMethod mSleep1 = cThread.getDeclaredMethod("sleep", new CtClass[] { CtClass.longType });
+ CtMethod mSleep2 = cThread.getDeclaredMethod("sleep", new CtClass[] { CtClass.longType, CtClass.intType });
+
+ CodeConverter codeConverter = new CodeConverter();
+
+ codeConverter.insertBeforeMethod(mSleep1, mBeginWait);
+ codeConverter.insertAfterMethod(mSleep1, mEndWait);
+
+ /*
+ codeConverter.insertBeforeMethod(mSleep2, mBeginWait);
+ codeConverter.insertAfterMethod(mSleep2, mEndWait);
+ */
+
+ cThread.instrument(codeConverter);
+
+
+ /*
+ method.instrument(new ExprEditor() {
+ public void edit(MethodCall m) throws CannotCompileException {
+ org.jboss.profiler.agent.Profiler.getProfilerThread(Thread.currentThread()).beginWait();
+
+ org.jboss.profiler.agent.Profiler.getProfilerThread(Thread.currentThread()).endWait();
+ }
+ });
+ */
+ /*
+ method.insertBefore("{ " +
+ "org.jboss.profiler.agent.Profiler.getProfilerThread(Thread.currentThread()).beginWait();" +
+ " }");
+
+ method.insertAfter("{ " +
+ "org.jboss.profiler.agent.Profiler.getProfilerThread(Thread.currentThread()).endWait();" +
+ " }", true);
+ */
+ } catch(Exception e) {
+ e.printStackTrace(System.err);
+ }
+ }
}
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/Profiler.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -317,6 +317,22 @@
}
/**
+ * Register start wait time for a method
+ */
+ public static void beginWait(Thread t, long l) {
+ System.out.print("BeginWait called");
+ getProfilerThread(Thread.currentThread()).beginWait();
+ }
+
+ /**
+ * Register end wait time for a method
+ */
+ public static void endWait(Thread t, long l) {
+ System.out.print("EndWait called");
+ getProfilerThread(Thread.currentThread()).endWait();
+ }
+
+ /**
* Get the root directory
* @return The root directory
*/
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThread.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThread.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThread.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -43,17 +43,13 @@
/**
* Register start wait time for a method
- * @param className The class name
- * @param methodName The method name
*/
- public void beginWait(String className, String methodName);
+ public void beginWait();
/**
* Register end wait time for a method
- * @param className The class name
- * @param methodName The method name
*/
- public void endWait(String className, String methodName);
+ public void endWait();
/**
* Class allocation
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThreadImpl.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThreadImpl.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/agent/ProfilerThreadImpl.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -175,15 +175,13 @@
/**
* Register start wait time for a method
- * @param className The class name
- * @param methodName The method name
*/
- public void beginWait(String className, String methodName) {
+ public void beginWait() {
if (!Agent.isEnabled() || !Agent.isCPU() || !Profiler.isRunning()) {
return;
}
- FrameInfo fi = findFrame(className, methodName);
+ FrameInfo fi = activeFrame;
if (fi == null) {
return;
@@ -194,17 +192,15 @@
/**
* Register end wait time for a method
- * @param className The class name
- * @param methodName The method name
*/
- public void endWait(String className, String methodName) {
+ public void endWait() {
long start = System.nanoTime();
if (!Agent.isEnabled() || !Agent.isCPU() || !Profiler.isRunning()) {
return;
}
- FrameInfo fi = findFrame(className, methodName);
+ FrameInfo fi = activeFrame;
if (fi == null) {
return;
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -632,7 +632,7 @@
DecimalFormat df = new DecimalFormat("#0.00");
bw.write("Total time: " + df.format(tci.getTotalTime()) + " ms" + NEW_LINE);
- //bw.write(" Wait time: " + df.format(tci.getWaitTime()) + " ms" + NEW_LINE);
+ bw.write(" Wait time: " + df.format(tci.getWaitTime()) + " ms" + NEW_LINE);
if (allocs != null && allocs.size() > 0) {
long alloc = 0;
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/cmd/Client.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -73,6 +73,7 @@
System.out.println(" diff : Difference between snapshots");
System.out.println(" add : Add classes (repository must be enabled)");
System.out.println(" remove : Remove classes (repository must be enabled)");
+ System.out.println(" list : List classes");
}
/**
@@ -231,6 +232,8 @@
cmd = new Command(CommandType.REMOVE_CLASSES, new Object[] { args[i] } );
i++;
}
+ } else if (cmdStr.equalsIgnoreCase("list")) {
+ cmd = new Command(CommandType.LIST_CLASSES);
} else {
usage();
return;
@@ -260,7 +263,8 @@
SnapshotUtil su = new SnapshotUtil(threshold);
su.dump(snapshot, f);
}
- } else if (cmd.getCommand() == CommandType.LIST_SNAPSHOTS) {
+ } else if (cmd.getCommand() == CommandType.LIST_SNAPSHOTS ||
+ cmd.getCommand() == CommandType.LIST_CLASSES) {
String[] result = (String[])remotingClient.invoke(cmd);
if (result != null) {
for (int j = 0; j < result.length; j++) {
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/connectors/AbstractHandler.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -69,6 +69,8 @@
Agent.addClasses((String)cmd.getArguments()[0], (Visibility)cmd.getArguments()[1]);
} else if (cmd.getCommand() == CommandType.REMOVE_CLASSES && Agent.isRepository()) {
Agent.removeClasses((String)cmd.getArguments()[0]);
+ } else if (cmd.getCommand() == CommandType.LIST_CLASSES) {
+ return Agent.listClasses();
}
return "";
}
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/shared/CommandType.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -95,5 +95,10 @@
/**
* Remove classes
*/
- REMOVE_CLASSES
+ REMOVE_CLASSES,
+
+ /**
+ * List classes
+ */
+ LIST_CLASSES
}
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/ui/ThreadHotspotBean.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/ui/ThreadHotspotBean.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/ui/ThreadHotspotBean.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -9,7 +9,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import javax.faces.model.SelectItem;
Modified: branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/Test.java
===================================================================
--- branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/Test.java 2008-10-06 02:41:56 UTC (rev 481)
+++ branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/Test.java 2008-10-20 20:50:52 UTC (rev 482)
@@ -104,6 +104,10 @@
* Method: F
*/
void f() {
+ try {
+ Thread.sleep(100L);
+ } catch (Exception e) {
+ }
}
/**
More information about the jboss-cvs-commits
mailing list