Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:bytemanproject/byteman

  • Loading branch information...
commit f6ada62525945a27556e4d9471ba8848bf4c2c87 2 parents 69958cb + 92a4704
@adinn adinn authored
View
43 contrib/dtest/src/org/jboss/byteman/contrib/dtest/Instrumentor.java
@@ -164,16 +164,43 @@ public void setRedirectedSubmissionsFile(File redirectedSubmissionsFile)
*/
public void injectOnCall(Class clazz, String methodName, String action) throws Exception
{
+ injectOnMethod(clazz, methodName, "true", action, "ENTRY");
+ }
+
+ /**
+ * Inject an action to take place upon exit of the specified class.method
+ *
+ * @param clazz The Class in which the injection point resides.
+ * @param methodName The method which should be intercepted.
+ * @param action The action that should take place upon invocation of the method.
+ * @throws Exception in case of failure.
+ */
+ public void injectOnExit(Class clazz, String methodName, String action) throws Exception
+ {
+ injectOnMethod(clazz, methodName, "true", action, "EXIT");
+ }
+
+ /**
+ * Inject an action to take place at a given point within the specified class.method
+ *
+ * @param clazz The Class in which the injection point resides.
+ * @param methodName The method which should be intercepted.
+ * @param action The action that should take place upon invocation of the method.
+ * @param where the injection point e.g. "ENTRY".
+ * @throws Exception in case of failure.
+ */
+ public void injectOnMethod(Class clazz, String methodName, String condition, String action, String where) throws Exception
+ {
String className = clazz.getCanonicalName();
- String ruleName = this.getClass().getCanonicalName()+"_"+className+"_"+methodName+"_callinjection";
+ String ruleName = this.getClass().getCanonicalName()+"_"+className+"_"+methodName+"_injectionat"+where;
RuleBuilder ruleBuilder = new RuleBuilder(ruleName);
- ruleBuilder.onClass(className).inMethod(methodName).atEntry();
+ ruleBuilder.onClass(className).inMethod(methodName).at(where);
ruleBuilder.usingHelper(BytemanTestHelper.class);
- ruleBuilder.whenTrue().doAction(action);
+ ruleBuilder.when(condition).doAction(action);
String ruleText = ruleBuilder.toString();
- installScript("onCall"+className+"."+methodName, ruleText);
+ installScript("onCall"+className+"."+methodName+"."+where, ruleText);
}
/**
@@ -282,7 +309,7 @@ public void crashAtMethodEntry(String className, String methodName) throws Excep
*/
public void crashAtMethod(String className, String methodName, String where) throws Exception
{
- String ruleName = this.getClass().getCanonicalName()+"_"+className+"_"+methodName+"_crashatexit";
+ String ruleName = this.getClass().getCanonicalName()+"_"+className+"_"+methodName+"_crashat"+where;
String action = "debug(\"killing JVM\"), killJVM()";
@@ -291,7 +318,7 @@ public void crashAtMethod(String className, String methodName, String where) thr
ruleBuilder.usingHelper(BytemanTestHelper.class);
ruleBuilder.whenTrue().doAction(action);
- installScript("crash"+className+"."+methodName, ruleBuilder.toString());
+ installScript("crash"+className+"."+methodName+"."+where, ruleBuilder.toString());
}
/**
@@ -303,7 +330,7 @@ public void crashAtMethod(String className, String methodName, String where) thr
* @param scriptString The text of the script i.e. one or more Rules.
* @throws Exception in case of failure.
*/
- private void installScript(String scriptName, String scriptString)
+ public void installScript(String scriptName, String scriptString)
throws Exception
{
System.out.println("installing: "+scriptString);
@@ -407,4 +434,4 @@ public void removeAllInstrumentation() throws Exception
submit.deleteScripts(installedScripts);
removeLocalState();
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.