chord.project.analyses
Class BasicDynamicAnalysis

java.lang.Object
  extended by chord.project.analyses.JavaAnalysis
      extended by chord.project.analyses.BasicDynamicAnalysis
All Implemented Interfaces:
ITask
Direct Known Subclasses:
DynamicAnalysis, DynamicReflectResolver

public class BasicDynamicAnalysis
extends JavaAnalysis

Generic implementation of a basic dynamic analysis. Custom dynamic analyses must extend either this class or class DynamicAnalysis.

Author:
Mayur Naik (mhn@cs.stanford.edu)

Field Summary
static boolean DEBUG
           
protected  java.util.Map<java.lang.String,java.lang.String> eventHandlerArgs
           
protected  java.util.Map<java.lang.String,java.lang.String> instrumentorArgs
           
protected  java.lang.String[] runIDs
           
 
Fields inherited from class chord.project.analyses.JavaAnalysis
consumes, controls, name, produces
 
Constructor Summary
BasicDynamicAnalysis()
           
 
Method Summary
 boolean canReuseTraces()
           
 void doneAllPasses()
          Subclasses can override this method.
 void donePass()
          Subclasses can override this method.
 java.util.Map<java.lang.String,java.lang.String> getEventHandlerArgs()
          Arguments to be passed to the event handler.
 java.lang.Class getEventHandlerClass()
          The class of the event handler to be used.
 java.lang.String getInstrKind()
          Subclasses can override this method.
 java.util.Map<java.lang.String,java.lang.String> getInstrumentorArgs()
          Arguments to be passed to the instrumentor.
 java.lang.Class getInstrumentorClass()
          The class of the instrumentor to be used.
 int getTimeout()
          Subclasses can override this method.
 int getTraceBlockSize()
          Subclasses can override this method.
protected  java.lang.String getTraceFileName(int version)
           
protected  java.lang.String getTraceFileName(int version, java.lang.String runID)
           
protected  java.lang.String getTraceFileName(java.lang.String base, int version)
           
protected  java.lang.String getTraceFileName(java.lang.String base, int version, java.lang.String runID)
           
 java.lang.String getTraceKind()
          Subclasses can override this method.
 java.util.List<java.lang.Runnable> getTraceTransformers()
          Subclasses can override this method.
 boolean haltOnErr()
          Subclasses can override this method.
 void handleEvent(ByteBufferedFile buffer)
           
 void initAllPasses()
          Subclasses can override this method.
 void initPass()
          Subclasses can override this method.
 void processTrace(java.lang.String fileName)
           
 boolean reuseTraces()
          Subclasses can override this method.
 void run()
          Executes this analysis in a "classic" project.
 boolean useJvmti()
          Determines whether or not this dynamic analysis must use the JVMTI agent implemented in main/agent/ in order to start and end the event handler at runtime.
 
Methods inherited from class chord.project.analyses.JavaAnalysis
getName, run, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values

eventHandlerArgs

protected java.util.Map<java.lang.String,java.lang.String> eventHandlerArgs

instrumentorArgs

protected java.util.Map<java.lang.String,java.lang.String> instrumentorArgs

runIDs

protected java.lang.String[] runIDs
Constructor Detail

BasicDynamicAnalysis

public BasicDynamicAnalysis()
Method Detail

getEventHandlerArgs

public java.util.Map<java.lang.String,java.lang.String> getEventHandlerArgs()
Arguments to be passed to the event handler. If this dynamic analysis is multi-JVM (uses separate JVMs for generating and handling events), then the following arguments are passed to the event handler by default: 1. trace_block_size= 2. trace_file= If this dynamic analysis is single-JVM, then no arguments are passed to the event handler by default. Whether or not this dynamic analysis is single- or multi-JVM is determined by method getEventHandlerClass(). If this method returns a subclass of TraceEventHandler, then it is multi-JVM; otherwise, it is single-JVM. The value of is determined by method getTraceBlockSize(). The value of is determined by method getTraceFileName(int). Subclasses can override this method but must call super.getEventHandlerArgs(), add any additional arguments to the returned map, and return that same map.


getInstrumentorArgs

public java.util.Map<java.lang.String,java.lang.String> getInstrumentorArgs()
Arguments to be passed to the instrumentor. If this dynamic analysis uses the JVMTI agent implemented in main/agent/ to start and end the event handler at runtime, then the only argument passed to the instrumentor by default is use_jvmti=true. If this dynamic analysis does not use the JVMTI agent, then the following arguments are passed to the instrumentor by default: 1. use_jvmti=false 2. event_handler_class= 3. event_handler_args=@@ ... @@ The reason these arguments are passed to the instrumentor is because, in the absence of the JVMTI agent, the instrumentor must inject calls to start and end the event handler at runtime, at the entry and exit, respectively, of the bytecode of the main method of the analyzed program. Whether or not this dynamic analysis uses the JVMTI agent is determined by method useJvmti(). The value of above is determined by method getEventHandlerClass(). The values of , , ..., , above are determined by method getEventHandlerArgs(). Subclasses can override this method but must call super.getInstrumentorArgs(), add any additional arguments to the returned map, and return that same map.


getInstrumentorClass

public java.lang.Class getInstrumentorClass()
The class of the instrumentor to be used. Subclasses can override this method but must return a class which is a subclass of BasicInstrumentor.


getEventHandlerClass

public java.lang.Class getEventHandlerClass()
The class of the event handler to be used. Subclasses can override this method but must return a class which extends BasicEventHandler. Additionally, if the dynamic analysis implemented by the subclass is multi-JVM (uses separate JVMs for generating and handling events), then this method must return a class which extends TraceEventHandler.


useJvmti

public boolean useJvmti()
Determines whether or not this dynamic analysis must use the JVMTI agent implemented in main/agent/ in order to start and end the event handler at runtime. If any dynamic analysis uses this JVMTI agent, then Chord must have been compiled by setting chord.use.jvmti=true (default is false) either on the command line or in file main/chord.properties. Subclasses can override this method.


getTraceTransformers

public java.util.List<java.lang.Runnable> getTraceTransformers()
Subclasses can override this method.


getInstrKind

public java.lang.String getInstrKind()
Subclasses can override this method.


getTraceKind

public java.lang.String getTraceKind()
Subclasses can override this method.


haltOnErr

public boolean haltOnErr()
Subclasses can override this method.


getTimeout

public int getTimeout()
Subclasses can override this method.


getTraceBlockSize

public int getTraceBlockSize()
Subclasses can override this method.


reuseTraces

public boolean reuseTraces()
Subclasses can override this method.


initPass

public void initPass()
Subclasses can override this method.


donePass

public void donePass()
Subclasses can override this method.


initAllPasses

public void initAllPasses()
Subclasses can override this method.


doneAllPasses

public void doneAllPasses()
Subclasses can override this method.


getTraceFileName

protected java.lang.String getTraceFileName(java.lang.String base,
                                            int version,
                                            java.lang.String runID)

getTraceFileName

protected java.lang.String getTraceFileName(java.lang.String base,
                                            int version)

getTraceFileName

protected java.lang.String getTraceFileName(int version)

getTraceFileName

protected java.lang.String getTraceFileName(int version,
                                            java.lang.String runID)

canReuseTraces

public boolean canReuseTraces()

run

public void run()
Description copied from interface: ITask
Executes this analysis in a "classic" project. This method must usually not be called directly. The correct way to call it is to call ClassicProject.runTask(String) or ClassicProject.runTask(ITask), providing this analysis either by its name or its object.

Specified by:
run in interface ITask
Overrides:
run in class JavaAnalysis

processTrace

public void processTrace(java.lang.String fileName)

handleEvent

public void handleEvent(ByteBufferedFile buffer)
                 throws java.io.IOException,
                        ReadException
Throws:
java.io.IOException
ReadException