The Meta-Environment API

toolbus.viewer
Class DebugToolBus

java.lang.Object
  extended by toolbus.ToolBus
      extended by toolbus.viewer.DebugToolBus

public class DebugToolBus
extends ToolBus

A specialized version of the ToolBus, which executes the process logic in debug mode. Viewer implementations need to use this ToolBus instead of the regular one.

Author:
Arnold Lankamp

Nested Class Summary
 
Nested classes/interfaces inherited from class toolbus.ToolBus
ToolBus.ProcessInstanceIterator
 
Field Summary
private  boolean breakWhileStepping
           
private  int currentState
           
private  boolean doRun
           
private  boolean doStep
           
private  long nextTime
           
private  PerformanceInformationHandler performanceInformationRetriever
           
private  toolbus.util.collections.ConcurrentHashSet<java.lang.String> processBreakPoints
           
private  toolbus.util.collections.ConcurrentHashSet<java.lang.Integer> processInstanceBreakPoints
           
private  java.lang.Object processLock
           
private  boolean running
           
private  java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> sourceCodeBreakPoints
           
private  toolbus.util.collections.ConcurrentHashSet<StateElement> stateElementBreakPoints
           
private  IViewer viewer
           
private  boolean workHasArrived
           
 
Fields inherited from class toolbus.ToolBus
connectionHandler, matchStore, nerrors, portNumber, processes, propertyManager, shuttingDown, tbfactory
 
Constructor Summary
DebugToolBus(java.lang.String[] args, IViewer viewer, IPerformanceMonitor performanceMonitor)
          Constructor.
 
Method Summary
 ProcessInstance addProcess(ProcessCall call)
          Add a process (as ProcessCall); previous two will become obsolete.
 void addProcessBreakPoint(java.lang.String processName)
          Adds a breakpoint for all the process instances whos type is identified by the given name.
 void addProcessInstanceBreakPoint(int processId)
          Adds a breakpoint for the process instance with the given id.
 void addSourceCodeBreakPoint(java.lang.String filename, int lineNumber)
          Adds a breakpoint on the given sourcecode coordinates.
 void addStateElementBreakPoint(StateElement stateElement)
          Adds a breakpoint on the given state element.
 void doRun()
          Notifies the debug toolbus that it should execute normally.
 void doStep()
          Notifies the debug toolbus that it should execute one step.
 void doStop()
          Notifies the debug toolbus that it should suspend its execution.
 void doTerminate()
          Requests the termination of the ToolBus.
 void execute()
          The main process loop of the ToolBus.
private  void fireStateChange(int state)
          Sends a notification to the attached Viewer that the ToolBus's state changed.
 aterm.ATerm getToolBusPerformanceStats()
          Gathers performance statistics related to JVM the current ToolBus is running in.
 void prepare()
           
 void removeProcessBreakPoint(java.lang.String processName)
          Removes the breakpoints for the process instances whos type is identified by the given name (if present).
 void removeProcessInstanceBreakPoint(int processId)
          Removes the breakpoint on the process instance with the given id (if present).
 void removeSourceCodeBreakPoint(java.lang.String filename, int lineNumber)
          Removes the breakpoint from the given source code coordinates (if present).
 void removeStateElementBreakPoint(StateElement stateElement)
          Removes the breakpoint from the given state element (if present).
 void setBreakWhileStepping(boolean breakWhileStepping)
          Tells the debug toolbus whether or not it should fire 'breakPointHit' events while stepping.
 void setNextTime(long next)
          Notifies the ToolBus that an atom with a delay on it, which could not be executed, has just been touched.
 void shutdown(aterm.ATerm msg)
          Terminates the ToolBus.
 void startMonitoringTool(aterm.ATerm toolKey)
          Initiates the monitoring of the tool associated with the given tool key (in case performance monitoring is enabled for this debug ToolBus).
 void startMonitorToolType(java.lang.String toolName)
          Initiates the monitoring of the given tool type (in case performance monitoring is enabled for this debug ToolBus).
 void stopMonitoringTool(aterm.ATerm toolKey)
          Stops monitoring the tool associated with the given tool key.
 void stopMonitoringToolType(java.lang.String toolName)
          Stops monitoring tools of the given type.
 void workArrived(ToolInstance toolInstance, byte operation)
          Notifies the ToolBus that work has arrived.
 
Methods inherited from class toolbus.ToolBus
addProcessDefinition, addToolDefinition, clearErrorsAndWarnings, dumpPerformanceStats, dumpUnhandledMessages, error, getDirectConnectionHandler, getIncludedScripts, getMatchStore, getPort, getPrintWriter, getProcessDefinition, getProcessDefinitions, getProcesses, getProperty, getProperty, getRunTime, getTBTermFactory, getToolDefinition, getToolDefinitions, getToolExecutorFactory, getToolInstanceManager, parsecup, parsecup1, setProperty, setToolExecutorFactory, showStatus, waitTillShutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentState

private volatile int currentState

running

private volatile boolean running

processLock

private final java.lang.Object processLock

workHasArrived

private volatile boolean workHasArrived

doRun

private volatile boolean doRun

doStep

private volatile boolean doStep

breakWhileStepping

private volatile boolean breakWhileStepping

viewer

private final IViewer viewer

processInstanceBreakPoints

private final toolbus.util.collections.ConcurrentHashSet<java.lang.Integer> processInstanceBreakPoints

processBreakPoints

private final toolbus.util.collections.ConcurrentHashSet<java.lang.String> processBreakPoints

stateElementBreakPoints

private final toolbus.util.collections.ConcurrentHashSet<StateElement> stateElementBreakPoints

sourceCodeBreakPoints

private final java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> sourceCodeBreakPoints

performanceInformationRetriever

private final PerformanceInformationHandler performanceInformationRetriever

nextTime

private long nextTime
Constructor Detail

DebugToolBus

public DebugToolBus(java.lang.String[] args,
                    IViewer viewer,
                    IPerformanceMonitor performanceMonitor)
Constructor.

Parameters:
args - The arguments the ToolBus need to start (like include path and main script name).
viewer - The viewer that is attached to this ToolBus.
performanceMonitor - The tool performance monitor to use (optional argument; pass null in case monitoring is not required).
Method Detail

addProcess

public ProcessInstance addProcess(ProcessCall call)
                           throws ToolBusException
Description copied from class: ToolBus
Add a process (as ProcessCall); previous two will become obsolete.

Overrides:
addProcess in class ToolBus
Throws:
ToolBusException
See Also:
ToolBus.addProcess(ProcessCall)

shutdown

public void shutdown(aterm.ATerm msg)
Terminates the ToolBus.

Overrides:
shutdown in class ToolBus
See Also:
ToolBus.shutdown(ATerm)

setNextTime

public void setNextTime(long next)
Description copied from class: ToolBus
Notifies the ToolBus that an atom with a delay on it, which could not be executed, has just been touched.

Overrides:
setNextTime in class ToolBus
Parameters:
next - The relative time in milliseconds that needs to elapse before the atom can be executed.
See Also:
ToolBus.setNextTime(long)

prepare

public void prepare()
Overrides:
prepare in class ToolBus

execute

public void execute()
The main process loop of the ToolBus.

Overrides:
execute in class ToolBus
See Also:
ToolBus.execute()

workArrived

public void workArrived(ToolInstance toolInstance,
                        byte operation)
Description copied from class: ToolBus
Notifies the ToolBus that work has arrived. This will wake the ToolBus's process loop up if it's currently sleeping.

Overrides:
workArrived in class ToolBus
Parameters:
toolInstance - The tool instance associated with the tool that send us data.
operation - The operation associated with the package that arrived.
See Also:
toolbus.ToolBus#workArrived()

getToolBusPerformanceStats

public aterm.ATerm getToolBusPerformanceStats()
Gathers performance statistics related to JVM the current ToolBus is running in.

Returns:
Performance statictics.

doRun

public void doRun()
Notifies the debug toolbus that it should execute normally.


doStop

public void doStop()
Notifies the debug toolbus that it should suspend its execution.


doStep

public void doStep()
Notifies the debug toolbus that it should execute one step.


doTerminate

public void doTerminate()
Requests the termination of the ToolBus.


fireStateChange

private void fireStateChange(int state)
Sends a notification to the attached Viewer that the ToolBus's state changed.

Parameters:
state - The state we changed to.

setBreakWhileStepping

public void setBreakWhileStepping(boolean breakWhileStepping)
Tells the debug toolbus whether or not it should fire 'breakPointHit' events while stepping. This parameter is set to true by default.

Parameters:
breakWhileStepping - The flag that indicates whether or not to break on breakpoints while stepping.

addProcessInstanceBreakPoint

public void addProcessInstanceBreakPoint(int processId)
Adds a breakpoint for the process instance with the given id. When the debug toolbus executes a state element in the associated process instance, the attached Viewer will be notified.

Parameters:
processId - The id of the process instance we want to add a breakpoint for.

removeProcessInstanceBreakPoint

public void removeProcessInstanceBreakPoint(int processId)
Removes the breakpoint on the process instance with the given id (if present).

Parameters:
processId - The id of the process instance we want to remove the breakpoint for.

addProcessBreakPoint

public void addProcessBreakPoint(java.lang.String processName)
Adds a breakpoint for all the process instances whos type is identified by the given name. When the debug toolbus executes a state element in one of those process instances, the attached Viewer will be notified.

Parameters:
processName - The name that identifies the type of process instances we want to add breakpoints for.

removeProcessBreakPoint

public void removeProcessBreakPoint(java.lang.String processName)
Removes the breakpoints for the process instances whos type is identified by the given name (if present).

Parameters:
processName - The name that identifies the type of process instance we want to remove the breakpoints for.

addStateElementBreakPoint

public void addStateElementBreakPoint(StateElement stateElement)
Adds a breakpoint on the given state element. When the debug toolbus executes the given state element, the attached Viewer will be notified.

Parameters:
stateElement - The state element we want to add a breakpoint for.

removeStateElementBreakPoint

public void removeStateElementBreakPoint(StateElement stateElement)
Removes the breakpoint from the given state element (if present).

Parameters:
stateElement - The state element we want to remove the breakpoint from.

addSourceCodeBreakPoint

public void addSourceCodeBreakPoint(java.lang.String filename,
                                    int lineNumber)
Adds a breakpoint on the given sourcecode coordinates. When the debug toolbus executes a state element which's position information matches the sourcecode coordiates, the attached Viewer will be notified.

Parameters:
filename - The name of the sourcefile
lineNumber - The line number to add the breakpoint on. Note that sourcecode line numbers start counting at 0.

removeSourceCodeBreakPoint

public void removeSourceCodeBreakPoint(java.lang.String filename,
                                       int lineNumber)
Removes the breakpoint from the given source code coordinates (if present).

Parameters:
filename - The name of the sourcefile
lineNumber - The line number to remove the breakpoint for.

startMonitoringTool

public void startMonitoringTool(aterm.ATerm toolKey)
Initiates the monitoring of the tool associated with the given tool key (in case performance monitoring is enabled for this debug ToolBus).

Parameters:
toolKey - The tool key associated with the tool we want to monitor.

stopMonitoringTool

public void stopMonitoringTool(aterm.ATerm toolKey)
Stops monitoring the tool associated with the given tool key.

Parameters:
toolKey - The tool key associated with the tool which we want to stop monitoring.

startMonitorToolType

public void startMonitorToolType(java.lang.String toolName)
Initiates the monitoring of the given tool type (in case performance monitoring is enabled for this debug ToolBus).

Parameters:
toolName - The tool type of tool we want to monitor.

stopMonitoringToolType

public void stopMonitoringToolType(java.lang.String toolName)
Stops monitoring tools of the given type.

Parameters:
toolName - The type of tool which we want to stop monitoring.

The Meta-Environment API