[jboss-svn-commits] JBL Code SVN: r26826 - in labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent: adapter and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jun 4 12:04:47 EDT 2009
Author: adinn
Date: 2009-06-04 12:04:47 -0400 (Thu, 04 Jun 2009)
New Revision: 26826
Modified:
labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/Transformer.java
labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/RuleTriggerMethodAdapter.java
labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/cfg/CFG.java
Log:
patched error in order of handler generation and added two new control switches to control dumping of control flow graph
Modified: labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/Transformer.java
===================================================================
--- labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/Transformer.java 2009-06-04 14:43:02 UTC (rev 26825)
+++ labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/Transformer.java 2009-06-04 16:04:47 UTC (rev 26826)
@@ -367,6 +367,18 @@
public static final String VERBOSE = BYTEMAN_PACKAGE_PREFIX + "verbose";
/**
+ * system property set (to any value) in order to switch on dumping of control flow graph for
+ * trigger method at each stage of construction
+ */
+ public static final String DUMP_CFG_PARTIAL = BYTEMAN_PACKAGE_PREFIX + "dump.cfg.partial";
+
+ /**
+ * system property set (to any value) in order to switch on dumping of control flow graph for
+ * triger method after construction
+ */
+ public static final String DUMP_CFG = BYTEMAN_PACKAGE_PREFIX + "dump.cfg";
+
+ /**
* system property set (to any value) in order to switch on debug statements in the default Helper
*/
@@ -489,6 +501,24 @@
}
/**
+ * check whether dumping of the control flow graph for the trigger class is enabled
+ * @return true if dumping is enabled etherwise false
+ */
+ public static boolean isDumpCFG()
+ {
+ return dumpCFG;
+ }
+
+ /**
+ * check whether dumping of the control flow graph for the trigger class during construction is enabled
+ * @return true if dumping is enabled etherwise false
+ */
+ public static boolean isDumpCFGPartial()
+ {
+ return dumpCFGPartial;
+ }
+
+ /**
* check whether debug mode for rule processing is enabled or disabled
* @return true if debug mode is enabled or verbose mode is enabled otherwise false
*/
@@ -541,6 +571,16 @@
private final static boolean verbose = (System.getProperty(VERBOSE) != null);
/**
+ * switch to control control flow graph output during rule processing
+ */
+ private final static boolean dumpCFGPartial = (System.getProperty(DUMP_CFG_PARTIAL) != null);
+
+ /**
+ * switch to control control flow graph output during rule processing
+ */
+ private final static boolean dumpCFG = (dumpCFGPartial || (System.getProperty(DUMP_CFG) != null));
+
+ /**
* switch to control verbose output during rule processing
*/
private final static boolean debug = (System.getProperty(DEBUG) != null);
Modified: labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/RuleTriggerMethodAdapter.java
===================================================================
--- labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/RuleTriggerMethodAdapter.java 2009-06-04 14:43:02 UTC (rev 26825)
+++ labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/RuleTriggerMethodAdapter.java 2009-06-04 16:04:47 UTC (rev 26826)
@@ -498,19 +498,19 @@
CodeLocation enterLocation = openEnters.get(listIdx);
int varIdx = cfg.getSavedMonitorIdx(enterLocation);
// call super method to avoid indexing these instructions
- super.visitIntInsn(Opcodes.ALOAD, varIdx);
- super.visitInsn(Opcodes.MONITOREXIT);
+ visitIntInsn(Opcodes.ALOAD, varIdx);
+ visitInsn(Opcodes.MONITOREXIT);
}
// throw must be in scope of the try catch
// call super method to avoid creating new blocks
- super.visitInsn(Opcodes.ATHROW);
+ visitInsn(Opcodes.ATHROW);
+ // add try catch blocks for each of the exception types
+ visitTryCatchBlock(newStart, newEnd, newEarlyReturn, EARLY_RETURN_EXCEPTION_TYPE_NAME);
+ visitTryCatchBlock(newStart, newEnd, newThrow, THROW_EXCEPTION_TYPE_NAME);
+ // this comes last because it is the superclass of the previous two
+ visitTryCatchBlock(newStart, newEnd, newExecute, EXECUTE_EXCEPTION_TYPE_NAME);
+ // now visit label so they get processed
visitLabel(newEnd);
- // now add try catch blocks for each of the exception types -- use super call to avoid
- // normal inhibition of try catch generation
- super.visitTryCatchBlock(newStart, newEnd, newEarlyReturn, EARLY_RETURN_EXCEPTION_TYPE_NAME);
- super.visitTryCatchBlock(newStart, newEnd, newExecute, EXECUTE_EXCEPTION_TYPE_NAME);
- // this comes last because it is the superclass of the previous two
- super.visitTryCatchBlock(newStart, newEnd, newThrow, THROW_EXCEPTION_TYPE_NAME);
// and update the details so it will catch these exceptions
details.setStart(newStart);
details.setEnd(newEnd);
@@ -532,21 +532,21 @@
}
if (Transformer.isVerbose()) {
- super.getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
- super.visitLdcInsn("caught ReturnException");
- super.invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println(String)"));
+ getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
+ visitLdcInsn("caught ReturnException");
+ invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println(String)"));
}
// add exception handling code subclass first
if (returnType == Type.VOID_TYPE) {
// drop exception and just return
- super.pop();
- super.visitInsn(Opcodes.RETURN);
+ pop();
+ visitInsn(Opcodes.RETURN);
} else {
// fetch value from exception, unbox if needed and return value
Method getReturnValueMethod = Method.getMethod("Object getReturnValue()");
- super.invokeVirtual(EARLY_RETURN_EXCEPTION_TYPE, getReturnValueMethod);
- super.unbox(returnType);
- super.returnValue();
+ invokeVirtual(EARLY_RETURN_EXCEPTION_TYPE, getReturnValueMethod);
+ unbox(returnType);
+ returnValue();
}
iterator = cfg.triggerDetails();
@@ -557,14 +557,14 @@
}
if (Transformer.isVerbose()) {
- super.getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
- super.visitLdcInsn("caught ThrowException");
- super.invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println(String)"));
+ getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
+ visitLdcInsn("caught ThrowException");
+ invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println(String)"));
}
// fetch value from exception, unbox if needed and return value
Method getThrowableMethod = Method.getMethod("Throwable getThrowable()");
- super.invokeVirtual(THROW_EXCEPTION_TYPE, getThrowableMethod);
- super.throwException();
+ invokeVirtual(THROW_EXCEPTION_TYPE, getThrowableMethod);
+ throwException();
// execute exception comes last because it is the super of the othher two classes
@@ -576,12 +576,13 @@
}
if (Transformer.isVerbose()) {
- super.getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
- super.visitLdcInsn("caught ExecuteException");
- super.invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println(String)"));
+ getStatic(Type.getType(System.class), "out", Type.getType(PrintStream.class));
+ visitLdcInsn("caught ExecuteException");
+ invokeVirtual(Type.getType(PrintStream.class), Method.getMethod("void println(String)"));
}
// rethrow an execute exception
- super.throwException(EXECUTE_EXCEPTION_TYPE, rule.getName() + " execution exception ");
+ throwException(EXECUTE_EXCEPTION_TYPE, rule.getName() + " execution exception ");
+
super.visitMaxs(maxStack, maxLocals);
// hmm, don't think we need this
Modified: labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/cfg/CFG.java
===================================================================
--- labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/cfg/CFG.java 2009-06-04 14:43:02 UTC (rev 26825)
+++ labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/byteman/agent/adapter/cfg/CFG.java 2009-06-04 16:04:47 UTC (rev 26826)
@@ -534,7 +534,7 @@
*/
private void carryForward()
{
- if (Transformer.isVerbose()) {
+ if (Transformer.isDumpCFGPartial()) {
System.out.println("Carry forward for block " + current.getBlockIdx());
}
@@ -560,7 +560,7 @@
current.updateActiveTryStarts(openTryCatchStarts);
- if (Transformer.isVerbose()) {
+ if (Transformer.isDumpCFGPartial()) {
System.out.println(current);
}
@@ -581,7 +581,7 @@
int entersCount = current.getMonitorEnterCount();
int exitsCount = current.getMonitorExitCount();
- if (Transformer.isVerbose()) {
+ if (Transformer.isDumpCFGPartial()) {
System.out.print("Carry forward open monitors for " + current.getBlockIdx() +" ==>" );
for (int i = 0; i < openEntersCount; i++) {
System.out.print(" ");
@@ -651,7 +651,7 @@
openEnters = openMonitorEnters.get(label);
if (openEnters == null) {
openMonitorEnters.put(label, newOpenEnters);
- if (Transformer.isVerbose()) {
+ if (Transformer.isDumpCFGPartial()) {
System.out.print("open monitors " + label + " ==>");
for (int j = 0; j < newOpenCount; j++) {
CodeLocation l = newOpenEnters.get(j);
@@ -1086,7 +1086,7 @@
{
// we don't need to do anything here to but for now just dump the CFG if we are verbose
- if (Transformer.isVerbose()) {
+ if (Transformer.isDumpCFG()) {
System.out.println(this);
}
}
More information about the jboss-svn-commits
mailing list