The main emulator class. More...
#include <GXemul.h>
Public Types | |
enum | RunState { Paused, SingleStepping, Running, Quitting } |
Public Member Functions | |
GXemul () | |
Creates a GXemul instance. More... | |
bool | ParseFilenames (string templateMachine, int filenameCount, char *filenames[]) |
Parses command line arguments (file names). More... | |
void | ClearEmulation () |
Discards the current emulation, and starts anew with just an empty root component. More... | |
void | InitUI () |
Initializes the UI. More... | |
int | Run () |
Runs GXemul's main loop. More... | |
const string & | GetEmulationFilename () const |
Gets the current emulation setup's filename. More... | |
void | SetEmulationFilename (const string &filename) |
Sets the current emulation setup's filename. More... | |
CommandInterpreter & | GetCommandInterpreter () |
Gets a reference to the CommandInterpreter. More... | |
UI * | GetUI () |
Gets a pointer to the GXemul instance' active UI. More... | |
refcount_ptr< Component > | GetRootComponent () |
Gets a pointer to the root configuration component. More... | |
const refcount_ptr< Component > | GetRootComponent () const |
void | SetRootComponent (refcount_ptr< Component > newRootComponent) |
Sets the root component, discarding the previous one. More... | |
bool | Reset () |
Resets the emulation. More... | |
void | Interrupt () |
Interrupts emulation. More... | |
bool | IsInterrupting () const |
Returns whether or not the current emulation is being interrupted. More... | |
void | SetRunState (RunState newState) |
Sets the RunState. More... | |
RunState | GetRunState () const |
Gets the current RunState. More... | |
string | GetRunStateAsString () const |
Gets the current RunState as a string. More... | |
uint64_t | GetStep () const |
Gets the current step of the emulation. More... | |
bool | GetSnapshottingEnabled () const |
Checks whether snapshots are currently enabled or not. More... | |
void | SetSnapshottingEnabled (bool enabled) |
Sets whether or not to use snapshots. More... | |
bool | GetQuietMode () const |
Gets the current quiet mode setting. More... | |
void | SetQuietMode (bool quietMode) |
Sets whether or not to run in quiet mode. More... | |
void | SetNrOfSingleStepsInARow (uint64_t steps) |
Sets the nr of single-steps to perform in a row. More... | |
bool | ModifyStep (int64_t oldStep, int64_t newStep) |
Change step either forwards or backwards. More... | |
void | Execute (const int longestTotalRun=100000) |
Run the emulation for "a while". More... | |
bool | IsTemplateMachine (const string &templateName) const |
Static Public Member Functions | |
static void | ListTemplates () |
Dump a list to stdout with all available machine templates. More... | |
static string | Version () |
Returns the GXemul version string. More... | |
static void | DumpMachineAsHTML (const string &machineName) |
static void | GenerateHTMLListOfComponents (bool machines) |
static void | RunUnitTests (int &nSucceeded, int &nFailures) |
The main emulator class.
A GXemul instance basically has the following member variables:
enum GXemul::RunState |
GXemul::GXemul | ( | ) |
void GXemul::ClearEmulation | ( | ) |
Discards the current emulation, and starts anew with just an empty root component.
Definition at line 192 of file GXemul.cc.
References GetRunState(), GetUI(), Paused, Running, SetRunState(), and UI::UpdateUI().
Referenced by CloseCommand::Execute(), and GXemul().
|
static |
Definition at line 266 of file GXemul.cc.
References ComponentFactory::CreateComponent(), Component::GenerateTreeDump(), Component::GetChildren(), and refcount_ptr< T >::IsNULL().
Referenced by internal_w().
void GXemul::Execute | ( | const int | longestTotalRun = 100000 | ) |
Run the emulation for "a while".
When single-stepping, this function will:
When not single-stepping, components will execute multiple steps at once, if possible. In the most common case (no breakpoints or other special cases), when this function returns, the run state will not have been affected.
longestTotalRun | Maximum number of steps to execute. |
Definition at line 894 of file GXemul.cc.
Referenced by ConsoleUI::MainLoop(), and ModifyStep().
|
static |
Definition at line 279 of file GXemul.cc.
References ComponentFactory::CreateComponent(), Component::GenerateTreeDump(), ComponentFactory::GetAllComponentNames(), ComponentFactory::GetAttribute(), Component::GetChildren(), ComponentFactory::HasAttribute(), and refcount_ptr< T >::IsNULL().
Referenced by internal_w().
CommandInterpreter & GXemul::GetCommandInterpreter | ( | ) |
Gets a reference to the CommandInterpreter.
Definition at line 631 of file GXemul.cc.
Referenced by HelpCommand::Execute(), and Reset().
const string & GXemul::GetEmulationFilename | ( | ) | const |
Gets the current emulation setup's filename.
Definition at line 617 of file GXemul.cc.
Referenced by SaveCommand::Execute(), and LoadCommand::Execute().
bool GXemul::GetQuietMode | ( | ) | const |
Gets the current quiet mode setting.
Definition at line 788 of file GXemul.cc.
Referenced by Reset(), Run(), and ConsoleUI::ShowDebugMessage().
const refcount_ptr< Component > GXemul::GetRootComponent | ( | ) |
Gets a pointer to the root configuration component.
Definition at line 667 of file GXemul.cc.
Referenced by BackwardStepCommand::Execute(), GetStep(), ConsoleUI::MainLoop(), Reset(), and Run().
const refcount_ptr<Component> GXemul::GetRootComponent | ( | ) | const |
GXemul::RunState GXemul::GetRunState | ( | ) | const |
Gets the current RunState.
Definition at line 749 of file GXemul.cc.
Referenced by ClearEmulation(), CPUDyntransComponent::DyntransToBeTranslatedDone(), CPUDyntransComponent::Execute(), Interrupt(), ConsoleUI::MainLoop(), ModifyStep(), ParseFilenames(), and Run().
string GXemul::GetRunStateAsString | ( | ) | const |
Gets the current RunState as a string.
Definition at line 755 of file GXemul.cc.
References Paused, Quitting, Running, and SingleStepping.
Referenced by StatusCommand::Execute().
bool GXemul::GetSnapshottingEnabled | ( | ) | const |
Checks whether snapshots are currently enabled or not.
Definition at line 772 of file GXemul.cc.
Referenced by Component::CheckVariableWrite(), and ModifyStep().
uint64_t GXemul::GetStep | ( | ) | const |
Gets the current step of the emulation.
Definition at line 637 of file GXemul.cc.
References GetRootComponent(), Component::GetVariable(), and StateVariable::ToInteger().
Referenced by StatusCommand::Execute(), and ModifyStep().
UI * GXemul::GetUI | ( | ) |
Gets a pointer to the GXemul instance' active UI.
Note: Never NULL. The UI may be the NullUI, or another UI (such as the ConsoleUI).
Definition at line 661 of file GXemul.cc.
Referenced by CommandInterpreter::AddKey(), ClearEmulation(), TestM88KMachine::Create(), TestMIPSMachine::Create(), SGI_IP30_Machine::Create(), ComponentFactory::CreateComponent(), ContinueBackwardsCommand::Execute(), StepCommand::Execute(), VersionCommand::Execute(), HelpCommand::Execute(), ListComponentsCommand::Execute(), BackwardStepCommand::Execute(), QuitCommand::Execute(), StatusCommand::Execute(), CPUDyntransComponent::Execute(), CPUComponent::ExecuteMethod(), CacheComponent::ExecuteMethod(), RAMComponent::ExecuteMethod(), ComponentFactory::GetCreationArgOverrides(), Component::GetUI(), InitUI(), ModifyStep(), RootComponent::PreRunCheckForComponent(), I960_CPUComponent::PreRunCheckForComponent(), MainbusComponent::PreRunCheckForComponent(), CPUComponent::PreRunCheckForComponent(), MIPS_CPUComponent::PreRunCheckForComponent(), M88K_CPUComponent::PreRunCheckForComponent(), Reset(), CommandInterpreter::ReshowCurrentCommandBuffer(), Run(), SetEmulationFilename(), SetRootComponent(), SetRunState(), SetSnapshottingEnabled(), and CPUComponent::ShowRegisters().
void GXemul::InitUI | ( | ) |
Initializes the UI.
Definition at line 545 of file GXemul.cc.
References GetUI(), and UI::Initialize().
void GXemul::Interrupt | ( | ) |
Interrupts emulation.
Only meaningful if RunState is Running or SingleStepping.
Definition at line 728 of file GXemul.cc.
References GetRunState(), Running, and SingleStepping.
|
inline |
Returns whether or not the current emulation is being interrupted.
Only meaningful if RunState is Running or SingleStepping.
Definition at line 178 of file GXemul.h.
Referenced by CPUComponent::FunctionTraceCall(), and CPUComponent::FunctionTraceReturn().
bool GXemul::IsTemplateMachine | ( | const string & | templateName | ) | const |
Definition at line 204 of file GXemul.cc.
References ComponentFactory::HasAttribute().
|
static |
Dump a list to stdout with all available machine templates.
Definition at line 239 of file GXemul.cc.
References ComponentFactory::GetAllComponentNames(), and ComponentFactory::GetAttribute().
bool GXemul::ModifyStep | ( | int64_t | oldStep, |
int64_t | newStep | ||
) |
Change step either forwards or backwards.
oldStep | The old step count. |
newStep | The new step count. |
Definition at line 809 of file GXemul.cc.
References Component::Clone(), Execute(), GetRunState(), GetSnapshottingEnabled(), GetStep(), GetUI(), Running, SetRootComponent(), SetRunState(), and UI::ShowDebugMessage().
Referenced by Component::CheckVariableWrite().
bool GXemul::ParseFilenames | ( | string | templateMachine, |
int | filenameCount, | ||
char * | filenames[] | ||
) |
Parses command line arguments (file names).
templateMachine | The template machine to use. |
filenameCount | for parsing command line options. |
filenames | for parsing command line options. |
Definition at line 427 of file GXemul.cc.
References GetRunState(), and Paused.
bool GXemul::Reset | ( | ) |
Resets the emulation.
This function recursively resets all components in the tree, and then executes the "on reset" commands (usually commands to load files into CPUs).
Definition at line 700 of file GXemul.cc.
References GetCommandInterpreter(), GetQuietMode(), GetRootComponent(), GetUI(), Component::Reset(), CommandInterpreter::RunCommand(), and UI::ShowDebugMessage().
Referenced by ResetCommand::Execute(), and Run().
int GXemul::Run | ( | ) |
Runs GXemul's main loop.
Definition at line 557 of file GXemul.cc.
References UI::FatalError(), Component::GenerateTreeDump(), Component::GetChildren(), GetQuietMode(), GetRootComponent(), GetRunState(), GetUI(), UI::MainLoop(), Paused, Reset(), Running, SetRunState(), UI::ShowDebugMessage(), and UI::ShowStartupBanner().
|
static |
void GXemul::SetEmulationFilename | ( | const string & | filename | ) |
Sets the current emulation setup's filename.
filename | This is the name of the file that is used for the current emulation setup. |
Definition at line 623 of file GXemul.cc.
References GetUI(), and UI::UpdateUI().
void GXemul::SetNrOfSingleStepsInARow | ( | uint64_t | steps | ) |
Sets the nr of single-steps to perform in a row.
steps | The number of steps, at least 1. |
Definition at line 800 of file GXemul.cc.
Referenced by StepCommand::Execute().
void GXemul::SetQuietMode | ( | bool | quietMode | ) |
Sets whether or not to run in quiet mode.
quietMode | true to run in quiet mode, false otherwise. |
Definition at line 794 of file GXemul.cc.
Referenced by CPUDyntransComponent::DyntransToBeTranslatedDone().
void GXemul::SetRootComponent | ( | refcount_ptr< Component > | newRootComponent | ) |
Sets the root component, discarding the previous one.
This function should not be used to set the root component to NULL. Use ClearEmulation() instead.
newRootComponent | A reference counted pointer to the new root component. It may not be a NULL pointer. |
Definition at line 679 of file GXemul.cc.
References Component::AsRootComponent(), GetUI(), refcount_ptr< T >::IsNULL(), RootComponent::SetOwner(), and UI::UpdateUI().
Referenced by ModifyStep().
void GXemul::SetRunState | ( | RunState | newState | ) |
Sets the RunState.
newState | The new RunState. |
Definition at line 741 of file GXemul.cc.
References GetUI(), and UI::UpdateUI().
Referenced by ClearEmulation(), StepCommand::Execute(), QuitCommand::Execute(), ContinueCommand::Execute(), PauseCommand::Execute(), ResetCommand::Execute(), ConsoleUI::MainLoop(), ModifyStep(), and Run().
void GXemul::SetSnapshottingEnabled | ( | bool | enabled | ) |
Sets whether or not to use snapshots.
enabled | true to enable snapshotting, false to disable it. |
Definition at line 778 of file GXemul.cc.
References GetUI(), and UI::ShowDebugMessage().
|
static |
Returns the GXemul version string.
Definition at line 509 of file GXemul.cc.
References COPYRIGHT_MSG, and SECONDARY_MSG.
Referenced by VersionCommand::Execute(), and ConsoleUI::ShowStartupBanner().