Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions java/daikon/chicory/Instrument24.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.lang.classfile.TypeKind;
import java.lang.classfile.attribute.CodeAttribute;
import java.lang.classfile.attribute.ConstantValueAttribute;
import java.lang.classfile.constantpool.ClassEntry;
import java.lang.classfile.constantpool.ConstantPoolBuilder;
import java.lang.classfile.constantpool.ConstantValueEntry;
import java.lang.classfile.constantpool.MethodRefEntry;
Expand Down Expand Up @@ -368,11 +369,21 @@ private void outputDebugFiles(byte[] classBytes, File directory, @BinaryName Str
private void instrumentClass(
ClassBuilder classBuilder, ClassModel classModel, ClassInfo classInfo) {

debugInstrument.log("Class Name:%n");
@SuppressWarnings("signature:assignment") // type conversion
@InternalForm String temp = classModel.thisClass().asInternalName();
debugInstrument.log(" %s%n", Signatures.internalFormToBinaryName(temp));

debugInstrument.log("Class Attributes:%n");
for (java.lang.classfile.Attribute<?> a : classModel.attributes()) {
debugInstrument.log(" %s%n", a);
}

debugInstrument.log("Class Interfaces:%n");
for (ClassEntry ce : classModel.interfaces()) {
debugInstrument.log(" %s%n", ce.asInternalName());
}

// Modify each non-void method to save its result in a local variable before returning.
instrument_all_methods(classModel, classBuilder, classInfo);

Expand Down Expand Up @@ -561,6 +572,9 @@ private void instrument_all_methods(
for (java.lang.classfile.Attribute<?> a : mm.attributes()) {
debugInstrument.log(" %s%n", a);
}
debugInstrument.log("mm.methodName: %s%n", mm.methodName().stringValue());
debugInstrument.log("mm.methodType: %s%n", mm.methodType().stringValue());

debugInstrument.log("mgen.getSignature: %s%n", mgen.getSignature());
MethodTypeDesc mtd = mm.methodTypeSymbol();
debugInstrument.log("mtd.descriptorString: %s%n", mtd.descriptorString());
Expand Down Expand Up @@ -815,6 +829,11 @@ private void instrumentCode(
}
codeList.add(ce);
}
// debug code
// case BranchInstruction bi -> {
// System.out.printf(" %s : %s%n", bi, bi.target());
// codeList.add(ce);
// }
default -> codeList.add(ce); // save all other elements
}
}
Expand Down Expand Up @@ -1361,10 +1380,12 @@ private boolean isConstructor(MethodGen24 mgen) {
if (mgen.isStatic()) {
param_offset = 0;
}

debugInstrument.log("create_method_info for: %s%n", classInfo.class_name);
if (debugInstrument.enabled) {
debugInstrument.log("create_method_info1 %s%n", paramNames.length);
for (int i = 0; i < paramNames.length; i++) {
debugInstrument.log("param: %s%n", paramNames[i]);
debugInstrument.log("param name: %s%n", paramNames[i]);
}
}

Expand Down Expand Up @@ -1404,7 +1425,7 @@ private boolean isConstructor(MethodGen24 mgen) {
if (debugInstrument.enabled) {
debugInstrument.log("create_method_info2 %s%n", paramNames.length);
for (int i = 0; i < paramNames.length; i++) {
debugInstrument.log("param: %s%n", paramNames[i]);
debugInstrument.log("param name: %s%n", paramNames[i]);
}
}

Expand All @@ -1429,6 +1450,13 @@ private boolean isConstructor(MethodGen24 mgen) {
arg_type_strings[i] = typeToClassGetName(paramTypes[i]);
}

if (debugInstrument.enabled) {
debugInstrument.log("create_method_info3 %s%n", paramTypes.length);
for (int ii = 0; ii < paramTypes.length; ii++) {
debugInstrument.log("param type: %s%n", arg_type_strings[ii]);
}
}

// Loop through each instruction and find the line number for each return opcode.
List<Integer> exit_locs = new ArrayList<>();

Expand Down
13 changes: 10 additions & 3 deletions java/daikon/dcomp/DCInstrument.java
Original file line number Diff line number Diff line change
Expand Up @@ -3055,22 +3055,29 @@ InstructionList multiarray2(Instruction inst) {
boolean should_track(@BinaryName String className, String methodName, String pptName) {

debugInstrument.log("Considering tracking ppt: %s, %s, %s%n", className, methodName, pptName);
debug_transform.log("Consider collecting data for ppt: %s%n", pptName);

// Don't track any JDK classes
if (BcelUtil.inJdk(className)) {
debug_transform.log("ignoring %s, is a JDK class%n", className);
debug_transform.log("not including as %s is a JDK class%n", className);
return false;
}

// Don't track toString methods because we call them in
// our debug statements.
if (pptName.contains("toString")) {
debug_transform.log("ignoring %s, is a toString method%n", pptName);
debug_transform.log("not including %s, as it is a toString method%n", pptName);
return false;
}

// call shouldIgnore to check ppt-omit-pattern(s) and ppt-select-pattern(s)
return !daikon.chicory.Instrument.shouldIgnore(className, methodName, pptName);
boolean shouldIgnore = daikon.chicory.Instrument.shouldIgnore(className, methodName, pptName);
if (shouldIgnore) {
debug_transform.log("ignoring %s, not included in ppt_select patterns%n", pptName);
} else {
debug_transform.log("including %s%n", pptName);
}
return !shouldIgnore;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion java/daikon/dcomp/DCRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ private static String obj_str(Object obj) {
}
String default_tostring =
String.format("%s@%s", obj.getClass().getName(), System.identityHashCode(obj));
if (tostring.equals(default_tostring)) {
if (tostring != null && tostring.equals(default_tostring)) {
return tostring;
} else {
// Limit display of object contents to 60 characters.
Expand Down
2 changes: 1 addition & 1 deletion java/daikon/dcomp/Premain.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static void premain(String agentArgs, Instrumentation inst) throws IOExce
(ClassFileTransformer)
loader.loadClass(instrumenter).getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException("Unexpected error loading Instrument", e);
throw new RuntimeException("Unexpected error loading Instrumenter " + instrumenter, e);
}
if (verbose) {
// If jdk_instrumented is true then the printf below will output
Expand Down