Package smsqmulator

Class MonitoredEmulationThread

java.lang.Object
java.lang.Thread
smsqmulator.MonitoredEmulationThread
All Implemented Interfaces:
Runnable, EmulationThread

public class MonitoredEmulationThread extends Thread implements EmulationThread
The independent thread that actually handles the emulation on a "g","gb" or "x" command. The MonitorGoThread may observe breakpoints. When a breakpoint is hit, execution of the 68K program stops.

The MonitorGoThread may log instructions. Logging is done to an internal data structure called a DebugList. Instructions executed are logged there but are only written to the log file when execution of the program stops. The DebugList is a fifo queue and only keeps a certain number of instructions (set up when this object is created).

This thread may also watch a memory location and stop excution when the content of that memory location changes (long word only).

This thread may also stop at a certain condition (eg register==value).

In "gofast" mode, no memory is watched, no breakpoints are checked etc - the program just executes as fast as it can.

  • Constructor Details

    • MonitoredEmulationThread

      public MonitoredEmulationThread(int nbrOfInstructions, Monitor monitor, boolean watchBreakpoints, int upperLogLimit, boolean checkmem, int memWatched, int provbreak, boolean excludeSuper, Screen screen, boolean loginstrs, int nbrLogs)
      Creates the monitor go thread.
      Parameters:
      nbrOfInstructions - how many instructions are to be executed, or 0 if continuous execution.
      monitor - the motor launching this goThread.
      watchBreakpoints - true if breakpoints should be observed.
      upperLogLimit - when logging instructions, instructions beyond this limit will NOT be logged (useful to exclude OS code in high mem).
      checkmem - set to true if memory is to be watched.
      memWatched - what memory address is to be watched.
      provbreak - provisional breakpoint used with traceover.
      excludeSuper - if true : when logging, exclude all instructions executed in supervisor mode.
      screen - the screen currently used to display the emulation.
      loginstrs - is true if instructions need to be logged.
      nbrLogs - how many instructions should be logged
  • Method Details

    • run

      public void run()
      Does the actual work : execute cpu instructions in a loop.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • done

      public void done(String message)
      This is called when the emulation stops.
      Parameters:
      message - the message to display.
    • endEmulation

      public void endEmulation()
      Specified by:
      endEmulation in interface EmulationThread
    • switchLogging

      public void switchLogging(boolean newLogState)
      Switches logging state on/off.
      Specified by:
      switchLogging in interface EmulationThread
      Parameters:
      newLogState - if true, logging is switched on again
    • switchSuper

      public void switchSuper(boolean superState)
      Do we log calls to the OS or only user state code?
      Parameters:
      superState - if true, only log calls in user mode.
    • setCondition

      public void setCondition(int dataReg, int addrReg, int condValue, boolean isContent, int address)
      Sets the condition for a "g" command
      Specified by:
      setCondition in interface EmulationThread
      Parameters:
      dataReg - the datareg this condition applies to, or -1 if condition is for address reg.
      addrReg - the addrreg this condition applies to, or -1 if condition is for data reg.
      condValue - the value to be met.
      isContent - possible content at...
      address - ...this address
    • signalDeath

      public void signalDeath(boolean b)
      Sets whether the death of the thread should be logged in the MonitorGui log wdw.
      Parameters:
      b - true if death should be logged.
    • setckmem

      public void setckmem(boolean b)
      Sets whether memory check should be switched on or off.
      Specified by:
      setckmem in interface EmulationThread
      Parameters:
      b - true if memory check is the switched on.
    • setmemWatched

      public void setmemWatched(int a)
      Sets the memory to be watched.
      Specified by:
      setmemWatched in interface EmulationThread
      Parameters:
      a - the mmemory to be watched : if content of memory location is changed the emulation breaks (in monitor mode).
    • setUpperLimit

      public void setUpperLimit(int address)
      Sets the upper limit of memory when logging.
      Specified by:
      setUpperLimit in interface EmulationThread
      Parameters:
      address - the upper limit of memory when logging any instruction executed above this will not be logged.
    • setScreenUpdateInterval

      public void setScreenUpdateInterval(int tim)
      Sets the interval between screen updates.
      Specified by:
      setScreenUpdateInterval in interface EmulationThread
      Parameters:
      tim - the interval between screen updates in milliseconds.