dumpByteCode flag
This commit is contained in:
+3
-2
@@ -76,10 +76,11 @@ public class ProfilingInstrumenterExample extends InterceptionInstrumenterAdapto
|
||||
}
|
||||
}
|
||||
|
||||
// Collect all strings that were capitalized using StringUtil
|
||||
// Collect all strings that were capitalized using StringUtil, and dump its instrumented byte code
|
||||
@MethodInterceptor(className = "com/intellij/openapi/util/text/StringUtil",
|
||||
methodName = "capitalize",
|
||||
methodDesc = "\\(Ljava/lang/String;\\).*")
|
||||
methodDesc = "\\(Ljava/lang/String;\\).*",
|
||||
dumpByteCode = true)
|
||||
public static Object c = new CollectFirstArguments();
|
||||
|
||||
public static class CollectFirstArguments {
|
||||
|
||||
+6
-5
@@ -37,9 +37,6 @@ public class InterceptionInstrumenter {
|
||||
private static final Pattern ANYTHING = Pattern.compile(".*");
|
||||
private static final Type OBJECT_TYPE = Type.getType(Object.class);
|
||||
|
||||
//private final boolean dumpInstrumentedMethods = true;
|
||||
private final boolean dumpInstrumentedMethods = false;
|
||||
|
||||
private final Map<String, ClassMatcher> classPatterns = new LinkedHashMap<String, ClassMatcher>();
|
||||
|
||||
private final Set<String> neverMatchedClassPatterns = new LinkedHashSet<String>();
|
||||
@@ -129,7 +126,8 @@ public class InterceptionInstrumenter {
|
||||
enterData,
|
||||
normalReturnData,
|
||||
exceptionData,
|
||||
annotation.logInterceptions());
|
||||
annotation.logInterceptions(),
|
||||
annotation.dumpByteCode());
|
||||
|
||||
for (Method dumpMethod : dumpMethods) {
|
||||
addDumpTask(interceptor, dumpMethod, instrumenter);
|
||||
@@ -305,6 +303,7 @@ public class InterceptionInstrumenter {
|
||||
|
||||
if (applicableInstrumenters.isEmpty()) return mv;
|
||||
|
||||
boolean dumpByteCode = false;
|
||||
final List<MethodData> normalReturnData = new ArrayList<MethodData>();
|
||||
final List<MethodData> enterData = new ArrayList<MethodData>();
|
||||
final List<MethodData> exceptionData = new ArrayList<MethodData>();
|
||||
@@ -314,11 +313,13 @@ public class InterceptionInstrumenter {
|
||||
normalReturnData.addAll(instrumenter.getNormalReturnData());
|
||||
|
||||
exceptionData.addAll(instrumenter.getExceptionData());
|
||||
|
||||
dumpByteCode |= instrumenter.shouldDumpByteCode();
|
||||
}
|
||||
|
||||
if (enterData.isEmpty() && normalReturnData.isEmpty() && exceptionData.isEmpty()) return mv;
|
||||
|
||||
if (dumpInstrumentedMethods) {
|
||||
if (dumpByteCode) {
|
||||
mv = getDumpingVisitorWrapper(mv, name, desc);
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -29,6 +29,7 @@ class MethodInstrumenter {
|
||||
private final List<MethodData> normalReturnData;
|
||||
private final List<MethodData> exceptionData;
|
||||
private final boolean logApplications;
|
||||
private final boolean dumpByteCode;
|
||||
|
||||
public MethodInstrumenter(
|
||||
String debugName,
|
||||
@@ -37,7 +38,9 @@ class MethodInstrumenter {
|
||||
boolean allowMultipleMatches,
|
||||
List<MethodData> enterData,
|
||||
List<MethodData> normalReturnData,
|
||||
List<MethodData> exceptionData, boolean logApplications
|
||||
List<MethodData> exceptionData,
|
||||
boolean logApplications,
|
||||
boolean dumpByteCode
|
||||
) {
|
||||
this.debugName = debugName;
|
||||
this.classPattern = classPattern;
|
||||
@@ -48,6 +51,7 @@ class MethodInstrumenter {
|
||||
this.normalReturnData = normalReturnData;
|
||||
this.exceptionData = exceptionData;
|
||||
this.logApplications = logApplications;
|
||||
this.dumpByteCode = dumpByteCode;
|
||||
}
|
||||
|
||||
public boolean allowsMultipleMatches() {
|
||||
@@ -76,6 +80,10 @@ class MethodInstrumenter {
|
||||
return exceptionData;
|
||||
}
|
||||
|
||||
boolean shouldDumpByteCode() {
|
||||
return dumpByteCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return debugName + "[" + classPattern + ":" + namePattern + " " + descPattern + (allowMultipleMatches ? " multiple" : "") + "]";
|
||||
|
||||
+3
@@ -38,4 +38,7 @@ public @interface MethodInterceptor {
|
||||
|
||||
// if true, every method instrumented with this interceptor will be logged to stdout
|
||||
boolean logInterceptions() default false;
|
||||
|
||||
// if true, byte codes of every method instrumented with this interceptor will be logged to stdout
|
||||
boolean dumpByteCode() default false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user