To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 3d925817 authored by john's avatar john
Browse files

add putstatic recording

parent 1254fa4e
......@@ -117,6 +117,58 @@ JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalLogPointerChange
}
}
/*
* Class: org_dacapo_instrument_Agent
* Method: internalLogPointerChange
* Signature: (Ljava/lang/Thread;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_org_dacapo_instrument_Agent_internalLogStaticPointerChange
(JNIEnv *jni_env, jclass agent_klass, jthread thread, jobject after, jclass object_klass, jobject before)
{
if (jvmRunning && !jvmStopped) {
jniNativeInterface* jni_table = JNIFunctionTable();
jlong thread_tag = 0;
jclass thread_klass = JVM_FUNC_PTR(jni_table,GetObjectClass)(jni_env,thread);
jlong thread_klass_tag = 0;
jlong before_tag = 0;
jclass before_klass = (before!=NULL)?JVM_FUNC_PTR(jni_table,GetObjectClass)(jni_env,before):NULL;
jlong before_klass_tag = 0;
jlong object_klass_tag = 0;
jlong after_tag = 0;
jclass after_klass = (after!=NULL)?JVM_FUNC_PTR(jni_table,GetObjectClass)(jni_env,after):NULL;
jlong after_klass_tag = 0;
rawMonitorEnter(&lockTag);
jboolean thread_has_new_tag = getTag(thread, &thread_tag);
jboolean thread_klass_has_new_tag = getTag(thread_klass, &thread_klass_tag);
jboolean before_has_new_tag = getTag(before, &before_tag);
jboolean before_klass_has_new_tag = getTag(before_klass, &before_klass_tag);
jboolean object_klass_has_new_tag = getTag(object_klass, &object_klass_tag);
jboolean after_has_new_tag = getTag(after, &after_tag);
jboolean after_klass_has_new_tag = getTag(after_klass, &after_klass_tag);
rawMonitorExit(&lockTag);
/* trace allocation */
rawMonitorEnter(&lockLog);
log_field_string(LOG_PREFIX_STATIC_POINTER);
log_field_current_time();
log_thread(thread,thread_tag,thread_has_new_tag,thread_klass,thread_klass_tag,thread_klass_has_new_tag);
log_class(object_klass,object_klass_tag,object_klass_has_new_tag);
log_field_jlong(before_tag);
log_class(before_klass,before_klass_tag,before_klass_has_new_tag);
log_field_jlong(after_tag);
log_class(after_klass,after_klass_tag,after_klass_has_new_tag);
log_eol();
rawMonitorExit(&lockLog);
}
}
/*
* Class: org_dacapo_instrument_Agent
* Method: internalAllocReport
......
......@@ -11,6 +11,7 @@
#define LOG_PREFIX_ALLOCATION "HA"
#define LOG_PREFIX_FREE "HF"
#define LOG_PREFIX_POINTER "HC"
#define LOG_PREFIX_STATIC_POINTER "HS"
#define LOG_PREFIX_CLASS_PREPARE "LD"
#define LOG_PREFIX_METHOD_PREPARE "LM"
......
......@@ -298,16 +298,12 @@ public final class Agent {
public static void start() {
if (agentThread.setLogon(true)) {
System.err.println("START:");
(new Exception()).printStackTrace();
internalStart();
}
}
public static void stop() {
if (agentThread.setLogon(false)) {
System.err.println("STOP:");
(new Exception()).printStackTrace();
internalStop();
}
}
......@@ -336,6 +332,14 @@ public final class Agent {
delayAllocReport.get().putfield(after, obj, before);
}
public static void logStaticPointerChange(Object after, Class klass, Object before) {
if (delayAllocReport.get()==null)
delayAllocReport.set(new DelayAllocReport());
// delayAllocReport.get().putfield(after, obj, before);
internalLogStaticPointerChange(Thread.currentThread(),after,klass,before);
}
public static void allocInc() {
if (delayAllocReport.get()==null)
delayAllocReport.set(new DelayAllocReport());
......@@ -390,6 +394,8 @@ public final class Agent {
private static native void internalLogPointerChange(Thread thread, Object after, Object obj, Object before);
private static native void internalLogStaticPointerChange(Thread thread, Object after, Object obj, Object before);
private static native void internalLogMonitorEnter(Thread thread, Object obj);
private static native void internalLogMonitorExit(Thread thread, Object obj);
......
......@@ -43,20 +43,24 @@ public class AllocateInstrument extends Instrument {
private static final String LOG_ALLOC_DONE = "allocDone";
private static final String LOG_ALLOC_REPORT = "allocReport";
private static final String LOG_POINTER_CHANGE = "logPointerChange";
private static final String LOG_STATIC_POINTER_CHANGE = "logStaticPointerChange";
private static final String LOG_INTERNAL_ALLOC_INC = INTERNAL_PREFIX + LOG_ALLOC_INC;
private static final String LOG_INTERNAL_ALLOC_DEC = INTERNAL_PREFIX + LOG_ALLOC_DEC;
private static final String LOG_INTERNAL_ALLOC_DONE = INTERNAL_PREFIX + LOG_ALLOC_DONE;
private static final String LOG_INTERNAL_ALLOC_REPORT = INTERNAL_PREFIX + LOG_ALLOC_REPORT;
private static final String LOG_INTERNAL_POINTER_CHANGE = INTERNAL_PREFIX + LOG_POINTER_CHANGE;
private static final String LOG_INTERNAL_STATIC_POINTER_CHANGE = INTERNAL_PREFIX + LOG_STATIC_POINTER_CHANGE;
private static final String LOG_INTERNAL_NAME = "org/dacapo/instrument/Log";
private static final String VOID_SIGNATURE = "()V";
private static final String OBJECT_SIGNATURE = "(Ljava/lang/Object;)V";
private static final String POINTER_CHANGE_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V";
private static final String STATIC_POINTER_CHANGE_SIGNATURE = "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/Object;)V";
private static final String JAVA_LANG_CLASS = org.objectweb.asm.Type.getInternalName(Class.class);
private static final Type JAVA_LANG_CLASS_TYPE = org.objectweb.asm.Type.getType(Class.class);
private static final String JAVA_LANG_CLASS = JAVA_LANG_CLASS_TYPE.getInternalName();
private static final String JAVA_LANG_CONSTRUCTOR = org.objectweb.asm.Type.getInternalName(java.lang.reflect.Constructor.class);
private static final String NEW_INSTANCE = "newInstance";
......@@ -221,7 +225,20 @@ public class AllocateInstrument extends Instrument {
mg.returnValue();
mg.endMethod();
} catch (NoSuchMethodException nsme) {
mg = new GeneratorAdapter(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, new Method(LOG_INTERNAL_STATIC_POINTER_CHANGE, STATIC_POINTER_CHANGE_SIGNATURE), STATIC_POINTER_CHANGE_SIGNATURE, new Type[] {}, this);
start = mg.mark();
mg.loadArgs();
mg.invokeStatic(Type.getType(k), Method.getMethod(k.getMethod(LOG_STATIC_POINTER_CHANGE, Object.class, Class.class, Object.class)));
end = mg.mark();
mg.returnValue();
mg.catchException(start, end, Type.getType(Throwable.class));
mg.returnValue();
mg.endMethod();
} catch (NoSuchMethodException nsme) {
System.err.println("Unable to find "+LOG_INTERNAL_NAME);
System.err.println("M:"+nsme);
nsme.printStackTrace();
......@@ -312,6 +329,24 @@ public class AllocateInstrument extends Instrument {
super.visitFieldInsn(Opcodes.GETFIELD,owner,fieldName,desc);
super.visitMethodInsn(Opcodes.INVOKESTATIC, name, LOG_INTERNAL_POINTER_CHANGE, POINTER_CHANGE_SIGNATURE);
}
} else if (logPointerChange && opcode == Opcodes.PUTSTATIC && desc.charAt(0) == 'L') {
// if (finalFields.contains(fieldName)) {
// // assume field is initially null
// super.visitInsn(Opcodes.DUP);
// } else {
// instrument reference changes from
// putstatic ...,v' => ...
// to
// dup ...,v' => ...,v',v'
// ldc owner.class ...,v',v' => ...,v',v',k
// getstatic ...,v',v',k => ...,v',v',k,v
// invokespecial staticpointerchangelog(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/Object;)V
// ...,v',v',k,v => ...,v'
super.visitInsn(Opcodes.DUP);
super.visitLdcInsn(Type.getObjectType(owner));
super.visitFieldInsn(Opcodes.GETSTATIC, owner, fieldName, desc);
super.visitMethodInsn(Opcodes.INVOKESTATIC, name, LOG_INTERNAL_STATIC_POINTER_CHANGE, STATIC_POINTER_CHANGE_SIGNATURE);
// }
}
super.visitFieldInsn(opcode,owner,fieldName,desc);
}
......
......@@ -53,6 +53,11 @@ public final class Log {
Agent.logPointerChange(after, obj, before);
}
public static void logStaticPointerChange(Object after, Class klass, Object before) {
if (available)
Agent.logStaticPointerChange(after, klass, before);
}
public static void allocInc() {
if (available)
Agent.allocInc();
......
......@@ -8,6 +8,7 @@ public final class LogTags {
public static final String LOG_PREFIX_ALLOCATION = "HA";
public static final String LOG_PREFIX_FREE = "HF";
public static final String LOG_PREFIX_POINTER = "HC";
public static final String LOG_PREFIX_STATIC_POINTER = "HS";
public static final String LOG_PREFIX_CLASS_PREPARE = "LD";
public static final String LOG_PREFIX_METHOD_PREPARE = "LM";
......
......@@ -106,6 +106,8 @@ public abstract class Event {
return new EventAllocation(is);
else if (EventPointerChange.TAG.equals(eventTag))
return new EventPointerChange(is);
else if (EventStaticPointerChange.TAG.equals(eventTag))
return new EventStaticPointerChange(is);
else if (EventFree.TAG.equals(eventTag))
return new EventFree(is);
else if (EventGC.TAG.equals(eventTag))
......
package org.dacapo.analysis.util.events;
import org.dacapo.analysis.util.CSVInputStream;
import org.dacapo.analysis.util.CSVOutputStream;
import org.dacapo.analysis.util.CSVInputStream.NoFieldAvailable;
import org.dacapo.analysis.util.CSVInputStream.ParseError;
import org.dacapo.instrument.LogTags;
public class EventStaticPointerChange extends Event implements EventHasThread {
public static final String TAG = LogTags.LOG_PREFIX_STATIC_POINTER;
private long threadTag;
private long threadClassTag;
private String threadClass;
private String threadName;
private Long classTag;
private String className;
private Long beforeTag;
private Long beforeClassTag;
private String beforeClassName;
private Long afterTag;
private Long afterClassTag;
private String afterClassName;
public EventStaticPointerChange(long time,
Long threadTag, Long threadClassTag, String threadClassName, String threadName,
Long classTag, String className,
Long beforeTag, Long beforeClassTag, String beforeClassName,
Long afterTag, Long afterClassTag, String afterClassName) {
super(time);
this.threadTag = threadTag;
this.threadClassTag = threadClassTag;
this.threadClass = threadClassName;
this.threadName = threadName;
this.classTag = classTag;
this.className = className;
this.beforeTag = beforeTag;
this.beforeClassTag = beforeClassTag;
this.beforeClassName = beforeClassName;
this.afterTag = afterTag;
this.afterClassTag = afterClassTag;
this.afterClassName = afterClassName;
}
public String getLogPrefix() {
return TAG;
}
protected void writeEvent(CSVOutputStream os) {
os.write(""+getTime());
EventThread.write(os, this);
os.write(""+classTag);
os.write(className);
os.write(""+beforeTag);
os.write(""+beforeClassTag);
os.write(beforeClassName);
os.write(""+afterTag);
os.write(""+afterClassTag);
os.write(afterClassName);
}
public long getThreadTag() { return threadTag; }
public void setThreadTag(long threadTag) { this.threadTag = threadTag; }
public long getThreadClassTag() { return threadClassTag; }
public void setThreadClassTag(long threadClassTag) { this.threadClassTag = threadClassTag; }
public String getThreadClass() { return threadClass; }
public void setThreadClass(String threadClass) { this.threadClass = threadClass; }
public String getThreadName() { return threadName; }
public void setThreadName(String threadName) { this.threadName = threadName; }
public Long getclassTag() { return classTag; }
public String getclassName() { return className; }
public Long getBeforeTag() { return beforeTag; }
public Long getBeforeClassTag() { return beforeClassTag; }
public String getBeforeClassName() { return beforeClassName; }
public Long getAfterTag() { return afterTag; }
public Long getAfterClassTag() { return afterClassTag; }
public String getAfterClassName() { return afterClassName; }
EventStaticPointerChange(CSVInputStream is) throws NoFieldAvailable, ParseError, EventParseException {
super(is);
EventThread.read(is, this);
this.classTag = is.nextFieldLong();
this.className = is.nextFieldString();
this.beforeTag = is.nextFieldLong();
this.beforeClassTag = is.nextFieldLong();
this.beforeClassName = is.nextFieldString();
this.afterTag = is.nextFieldLong();
this.afterClassTag = is.nextFieldLong();
this.afterClassName = is.nextFieldString();
if (is.numberOfFieldsLeft()!=0 && this instanceof EventStaticPointerChange)
throw new EventParseException("additional fields", null);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment