sofya.ed.semantic
Class TraceFileTarget

java.lang.Object
  extended by sofya.ed.semantic.TraceFileTarget
All Implemented Interfaces:
ChainedEventListener, ErrorRecorder, EventListener

public class TraceFileTarget
extends java.lang.Object
implements ChainedEventListener, ErrorRecorder

Generates a trace file of observed events.

Version:
11/15/2005
Author:
Alex Kinneer

Nested Class Summary
 
Nested classes/interfaces inherited from interface sofya.ed.semantic.EventListener
EventListener.Arguments, EventListener.CallData, EventListener.ExceptionData, EventListener.FieldData, EventListener.MethodData, EventListener.MonitorData, EventListener.NewAllocationData, EventListener.ObjectData, EventListener.ThreadData, EventListener.ThreadStatus
 
Field Summary
static int EOF
          Marker which is written to indicate the end of the file.
 
Constructor Summary
TraceFileTarget(java.io.File f, SemanticEventData egd)
          Creates a new trace file.
TraceFileTarget(java.lang.String fileName, SemanticEventData egd)
          Creates a new trace file.
 
Method Summary
 void callReturnEvent(EventListener.ThreadData td, EventListener.CallData cd, boolean exceptional)
          Notification that a thread has returned from a method call.
 void classPrepareEvent(EventListener.ThreadData td, java.lang.String className)
          Notification that a class was prepared (this is, loaded by the classloader).
 void constructorCallEvent(EventListener.ThreadData td, EventListener.CallData cd)
          Notification that a constructor was invoked.
 void constructorEnterEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a constructor was entered.
 void constructorExitEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a constructor was exited.
 void exceptionCatchEvent(EventListener.ThreadData td, EventListener.ExceptionData ed)
          Notification that an exception was caught.
 void exceptionThrowEvent(EventListener.ThreadData td, EventListener.ExceptionData ed)
          Notification that an exception was thrown.
 void executionStarted()
          Notification that the system has begun executing user code.
 java.lang.Exception getError()
          Gets the exception that put the trace file target in an error state.
static ChainedEventListenerFactory getFactory(SemanticEventData egd)
          Gets the factory for producing instances of this class on demand.
 ChainedEventListener getParent()
          Gets the parent of this listener in the listener chain.
 long getStreamID()
          Gets the unique identifier associated with this event stream.
 java.lang.String getStreamName()
          Gets an informational name associated with this event stream.
 boolean inError()
          Reports whether this trace file target is in an error state.
 void instanceFieldAccessEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.FieldData fd)
          Notification that an instance field was read.
 void instanceFieldWriteEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.FieldData fd)
          Notification that an instance field was written.
 void interfaceCallEvent(EventListener.ThreadData td, EventListener.CallData cd)
          Notification that an interface method was called.
 void monitorAcquireEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread has acquired a monitor.
 void monitorContendEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread is contending for a monitor.
 void monitorPreReleaseEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread is about to release a monitor.
 void monitorReleaseEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread has released a monitor.
 void newAllocationEvent(EventListener.ThreadData td, EventListener.NewAllocationData nad)
          Notification that an object was allocated by a NEW instruction.
 void rethrowError()
          Rethrows the originating exception if this trace file target is in an error state; does nothing if in a normal state.
 void staticCallEvent(EventListener.ThreadData td, EventListener.CallData cd)
          Notification that a static method was called.
 void staticFieldAccessEvent(EventListener.ThreadData td, EventListener.FieldData fd)
          Notification that a static field was read.
 void staticFieldWriteEvent(EventListener.ThreadData td, EventListener.FieldData fd)
          Notification that a static field was written.
 void staticInitializerEnterEvent(EventListener.ThreadData td, EventListener.MethodData md)
          Notification that a static initializer was entered.
 void staticMethodEnterEvent(EventListener.ThreadData td, EventListener.MethodData md)
          Notification that a static method was entered.
 void staticMethodExitEvent(EventListener.ThreadData td, EventListener.MethodData md)
          Notification that a static method was exited.
 void systemExited()
          Notification that the system has terminated.
 void systemStarted()
          Notification that the target virtual machine has been launched.
 void threadDeathEvent(EventListener.ThreadData td)
          Notification that a thread has terminated.
 void threadStartEvent(EventListener.ThreadData td)
          Notification that a thread has started.
 void virtualCallEvent(EventListener.ThreadData td, EventListener.CallData cd)
          Notification that a virtual method was called.
 void virtualMethodEnterEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a virtual method was entered.
 void virtualMethodExitEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a virtual method was exited.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOF

public static final int EOF
Marker which is written to indicate the end of the file.

See Also:
Constant Field Values
Constructor Detail

TraceFileTarget

public TraceFileTarget(java.lang.String fileName,
                       SemanticEventData egd)
                throws java.io.IOException
Creates a new trace file.

Parameters:
fileName - Name of the trace file that will be generated.
egd - Event dispatch data file produced by the instrumentor.
Throws:
java.io.IOException - If an error occurs when attempting to open the trace file for writing.

TraceFileTarget

public TraceFileTarget(java.io.File f,
                       SemanticEventData egd)
                throws java.io.IOException
Creates a new trace file.

Parameters:
f - Handle to the trace file that will be generated.
egd - Event dispatch data file produced by the instrumentor.
Throws:
java.io.IOException - If an error occurs when attempting to open the trace file for writing.
Method Detail

getFactory

public static ChainedEventListenerFactory getFactory(SemanticEventData egd)
Gets the factory for producing instances of this class on demand.

Parameters:
egd - Event dispatch data file produced by the instrumentor.
Returns:
A listener factory which produces instances of this class to generate independent trace files for subsets of the events dispatched from the observed system.

getParent

public ChainedEventListener getParent()
Description copied from interface: ChainedEventListener
Gets the parent of this listener in the listener chain.

Specified by:
getParent in interface ChainedEventListener
Returns:
The event listener from which this listener receives events.

getStreamID

public long getStreamID()
Description copied from interface: ChainedEventListener
Gets the unique identifier associated with this event stream.

Specified by:
getStreamID in interface ChainedEventListener
Returns:
An value which should uniquely identify this event stream, typically derived from some characteristic of the filtering criteria being applied by the parent listener.

getStreamName

public java.lang.String getStreamName()
Description copied from interface: ChainedEventListener
Gets an informational name associated with this event stream.

Specified by:
getStreamName in interface ChainedEventListener
Returns:
A string which provides some description of the nature of the events handled by this string.

inError

public boolean inError()
Reports whether this trace file target is in an error state.

Specified by:
inError in interface ErrorRecorder
Returns:
true if an error has occurred while trying to generate the trace file.

rethrowError

public void rethrowError()
                  throws java.lang.Exception
Rethrows the originating exception if this trace file target is in an error state; does nothing if in a normal state.

Specified by:
rethrowError in interface ErrorRecorder
Throws:
java.lang.Exception - If an error has been raised during the trace file generation.

getError

public java.lang.Exception getError()
Gets the exception that put the trace file target in an error state.

Specified by:
getError in interface ErrorRecorder
Returns:
The first unrecoverable exception occurred while trying to generate the trace file.

systemStarted

public void systemStarted()
Description copied from interface: EventListener
Notification that the target virtual machine has been launched.

Specified by:
systemStarted in interface EventListener

executionStarted

public void executionStarted()
Description copied from interface: EventListener
Notification that the system has begun executing user code.

This event will be preceded by thread start events.

Specified by:
executionStarted in interface EventListener

threadStartEvent

public void threadStartEvent(EventListener.ThreadData td)
Description copied from interface: EventListener
Notification that a thread has started. These events are not dependent on the module description.

Specified by:
threadStartEvent in interface EventListener
Parameters:
td - Information about the newly started thread.

threadDeathEvent

public void threadDeathEvent(EventListener.ThreadData td)
Description copied from interface: EventListener
Notification that a thread has terminated. These events are not dependent on the module description.

Specified by:
threadDeathEvent in interface EventListener
Parameters:
td - Information about the terminated thread.

classPrepareEvent

public void classPrepareEvent(EventListener.ThreadData td,
                              java.lang.String className)
Description copied from interface: EventListener
Notification that a class was prepared (this is, loaded by the classloader). These events are not dependent on the module description.

Specified by:
classPrepareEvent in interface EventListener
Parameters:
td - Information about the thread which caused the class to be prepared.
className - Name of the class which was prepared.

monitorContendEvent

public void monitorContendEvent(EventListener.ThreadData td,
                                EventListener.ObjectData od,
                                EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread is contending for a monitor.

Specified by:
monitorContendEvent in interface EventListener
Parameters:
td - Information about the thread which is contending for a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor contention.

monitorAcquireEvent

public void monitorAcquireEvent(EventListener.ThreadData td,
                                EventListener.ObjectData od,
                                EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread has acquired a monitor.

Specified by:
monitorAcquireEvent in interface EventListener
Parameters:
td - Information about the thread which acquired a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor acquisition.

monitorPreReleaseEvent

public void monitorPreReleaseEvent(EventListener.ThreadData td,
                                   EventListener.ObjectData od,
                                   EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread is about to release a monitor.

Specified by:
monitorPreReleaseEvent in interface EventListener
Parameters:
td - Information about the thread which is about to release a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor about to be released event..

monitorReleaseEvent

public void monitorReleaseEvent(EventListener.ThreadData td,
                                EventListener.ObjectData od,
                                EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread has released a monitor.

Specified by:
monitorReleaseEvent in interface EventListener
Parameters:
td - Information about the thread which released a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor release.

newAllocationEvent

public void newAllocationEvent(EventListener.ThreadData td,
                               EventListener.NewAllocationData nad)
Description copied from interface: EventListener
Notification that an object was allocated by a NEW instruction.

This event cannot yet associate a unique identifier with the object, because this event only represents the allocation of a reference to which an object of a given class may be assigned. In other words, no actual object has yet been created. A unique ID can be obtained once a constructor is executed, which is signaled by the EventListener.constructorEnterEvent(sofya.ed.semantic.EventListener.ThreadData, sofya.ed.semantic.EventListener.ObjectData, sofya.ed.semantic.EventListener.MethodData).

Specified by:
newAllocationEvent in interface EventListener
Parameters:
td - Information about the thread which allocated the object.
nad - Information about the new allocation.

constructorCallEvent

public void constructorCallEvent(EventListener.ThreadData td,
                                 EventListener.CallData cd)
Description copied from interface: EventListener
Notification that a constructor was invoked.

Specified by:
constructorCallEvent in interface EventListener
Parameters:
td - Information about the thread which invoked the constructor.
cd - Information about the particular constructor which was invoked.

constructorEnterEvent

public void constructorEnterEvent(EventListener.ThreadData td,
                                  EventListener.ObjectData od,
                                  EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a constructor was entered.

This is the first point during the object creation process at which the object can be uniquely identified.

Specified by:
constructorEnterEvent in interface EventListener
Parameters:
td - Information about the thread executing the constructor.
od - Information about the object under construction. At the time of this event, only the object ID will be valid.
md - Information about the entered constructor.

constructorExitEvent

public void constructorExitEvent(EventListener.ThreadData td,
                                 EventListener.ObjectData od,
                                 EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a constructor was exited.

NOTE: This event is raised only if the constructor completes normally. If a constructor throws an escaping exception, the object is not successfully created and thus further events related to the object are not possible.

Specified by:
constructorExitEvent in interface EventListener
Parameters:
td - Information about the thread executing the constructor.
od - Information about the object under construction. At the time of this event, only the object ID will be valid.
md - Information about the exited constructor.

staticFieldAccessEvent

public void staticFieldAccessEvent(EventListener.ThreadData td,
                                   EventListener.FieldData fd)
Description copied from interface: EventListener
Notification that a static field was read.

Specified by:
staticFieldAccessEvent in interface EventListener
Parameters:
td - Information about the thread in which the field access occurred.
fd - Information about the accessed field.

instanceFieldAccessEvent

public void instanceFieldAccessEvent(EventListener.ThreadData td,
                                     EventListener.ObjectData od,
                                     EventListener.FieldData fd)
Description copied from interface: EventListener
Notification that an instance field was read.

Specified by:
instanceFieldAccessEvent in interface EventListener
Parameters:
td - Information about the thread in which the field access occurred.
od - Information about the object which owns the accessed field.
fd - Information about the accessed field.

staticFieldWriteEvent

public void staticFieldWriteEvent(EventListener.ThreadData td,
                                  EventListener.FieldData fd)
Description copied from interface: EventListener
Notification that a static field was written.

Specified by:
staticFieldWriteEvent in interface EventListener
Parameters:
td - Information about the thread in which the field write occurred.
fd - Information about the written field.

instanceFieldWriteEvent

public void instanceFieldWriteEvent(EventListener.ThreadData td,
                                    EventListener.ObjectData od,
                                    EventListener.FieldData fd)
Description copied from interface: EventListener
Notification that an instance field was written.

Specified by:
instanceFieldWriteEvent in interface EventListener
Parameters:
td - Information about the thread in which the field write occurred.
od - Information about the object which owns the written field.
fd - Information about the written field.

staticCallEvent

public void staticCallEvent(EventListener.ThreadData td,
                            EventListener.CallData cd)
Description copied from interface: EventListener
Notification that a static method was called.

Specified by:
staticCallEvent in interface EventListener
Parameters:
td - Information about the thread which called the method.
cd - Information about the called method.

virtualCallEvent

public void virtualCallEvent(EventListener.ThreadData td,
                             EventListener.CallData cd)
Description copied from interface: EventListener
Notification that a virtual method was called.

Specified by:
virtualCallEvent in interface EventListener
Parameters:
td - Information about the thread which called the method.
cd - Information about the called method.

interfaceCallEvent

public void interfaceCallEvent(EventListener.ThreadData td,
                               EventListener.CallData cd)
Description copied from interface: EventListener
Notification that an interface method was called.

Specified by:
interfaceCallEvent in interface EventListener
Parameters:
td - Information about the thread which called the method.
cd - Information about the called method.

callReturnEvent

public void callReturnEvent(EventListener.ThreadData td,
                            EventListener.CallData cd,
                            boolean exceptional)
Description copied from interface: EventListener
Notification that a thread has returned from a method call.

Specified by:
callReturnEvent in interface EventListener
Parameters:
td - Information about the thread in which the method call returned.
cd - Information about the called method from which control returned.
exceptional - Flag indicating whether the method returned exceptionally.

virtualMethodEnterEvent

public void virtualMethodEnterEvent(EventListener.ThreadData td,
                                    EventListener.ObjectData od,
                                    EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a virtual method was entered.

Specified by:
virtualMethodEnterEvent in interface EventListener
Parameters:
td - Information about the thread executing the method.
od - Information about the object on which the virtual method was called.
md - Information about the entered method.

virtualMethodExitEvent

public void virtualMethodExitEvent(EventListener.ThreadData td,
                                   EventListener.ObjectData od,
                                   EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a virtual method was exited.

Specified by:
virtualMethodExitEvent in interface EventListener
Parameters:
td - Information about the thread executing the method.
od - Information about the object on which the virtual method was called.
md - Information about the exited method.

staticMethodEnterEvent

public void staticMethodEnterEvent(EventListener.ThreadData td,
                                   EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a static method was entered.

Specified by:
staticMethodEnterEvent in interface EventListener
Parameters:
td - Information about the thread executing the method.
md - Information about the entered method.

staticMethodExitEvent

public void staticMethodExitEvent(EventListener.ThreadData td,
                                  EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a static method was exited.

Specified by:
staticMethodExitEvent in interface EventListener
Parameters:
td - Information about the thread executing the method.
md - Information about the exited method.

exceptionThrowEvent

public void exceptionThrowEvent(EventListener.ThreadData td,
                                EventListener.ExceptionData ed)
Description copied from interface: EventListener
Notification that an exception was thrown.

Specified by:
exceptionThrowEvent in interface EventListener
Parameters:
td - Information about the thread in which the exception was thrown.
ed - Information about the thrown exception.

exceptionCatchEvent

public void exceptionCatchEvent(EventListener.ThreadData td,
                                EventListener.ExceptionData ed)
Description copied from interface: EventListener
Notification that an exception was caught.

Specified by:
exceptionCatchEvent in interface EventListener
Parameters:
td - Information about the thread in which the exception was caught.
ed - Information about the caught exception.

staticInitializerEnterEvent

public void staticInitializerEnterEvent(EventListener.ThreadData td,
                                        EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a static initializer was entered.

Specified by:
staticInitializerEnterEvent in interface EventListener
Parameters:
td - Information about the thread executing the static initializer.
md - Information about the entered static initializer.

systemExited

public void systemExited()
Description copied from interface: EventListener
Notification that the system has terminated.

Specified by:
systemExited in interface EventListener