50 "already at step 0.\n");
66 ss <<
"step " << step <<
" -> " << (step-1) <<
": ";
71 stringstream changeMessages;
74 string msg = changeMessages.str();
76 msg =
"No state change.\n";
86 return "Runs one step of the emulation backwards.";
93 "Runs one step of the emulation backwards. This command does the same as\n" 94 "manually decreasing root.step by 1, except that all state changes are also\n" 98 "step 3 -> 2: => cpu0.a1: 0 -> 0x2a\n" 99 " => cpu0.pc: 0xffffffffbfc0004c -> 0xffffffffbfc00048\n" 101 "This command requires that snapshotting support is enabled (using the\n" 102 "-B command line option).\n";
111 static void Test_BackwardStepCommand_AlreadyAtStep0()
114 vector<string> dummyArguments;
120 cmd->
Execute(gxemul, dummyArguments);
125 static void Test_BackwardStepCommand_NotWhenSnapshotsAreDisabled()
128 vector<string> dummyArguments;
132 char filename[] =
"test/FileLoader_ELF_MIPS";
133 char *filenames[] = { filename };
145 UnitTest::Assert(
"3: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff80010104");
146 UnitTest::Assert(
"3: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007ed0");
147 UnitTest::Assert(
"3: cpu0.v0", cpu->GetVariable(
"v0")->ToString(),
"0xffffffff88880000");
148 UnitTest::Assert(
"3: cpu0.v1", cpu->GetVariable(
"v1")->ToString(),
"0xffffffffcccc0000");
151 cmd->
Execute(gxemul, dummyArguments);
155 static void Test_BackwardStepCommand_Basic()
158 vector<string> dummyArguments;
162 char filename[] =
"test/FileLoader_ELF_MIPS";
163 char *filenames[] = { filename };
175 UnitTest::Assert(
"3: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff80010104");
176 UnitTest::Assert(
"3: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007ed0");
177 UnitTest::Assert(
"3: cpu0.v0", cpu->GetVariable(
"v0")->ToString(),
"0xffffffff88880000");
178 UnitTest::Assert(
"3: cpu0.v1", cpu->GetVariable(
"v1")->ToString(),
"0xffffffffcccc0000");
180 cmd->
Execute(gxemul, dummyArguments);
183 UnitTest::Assert(
"2: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff80010100");
184 UnitTest::Assert(
"2: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007ed0");
186 UnitTest::Assert(
"2: cpu0.v1", cpu->GetVariable(
"v1")->ToString(),
"0xffffffffcccc0000");
188 cmd->
Execute(gxemul, dummyArguments);
191 UnitTest::Assert(
"1: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff800100fc");
192 UnitTest::Assert(
"1: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007ed0");
196 cmd->
Execute(gxemul, dummyArguments);
199 UnitTest::Assert(
"0: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff800100f8");
200 UnitTest::Assert(
"0: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007f00");
204 cmd->
Execute(gxemul, dummyArguments);
207 UnitTest::Assert(
"X: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff800100f8");
208 UnitTest::Assert(
"X: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007f00");
214 static void Test_BackwardStepCommand_ManualAddAndLoad()
217 vector<string> dummyArguments;
230 UnitTest::Assert(
"3: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff80010104");
231 UnitTest::Assert(
"3: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007ed0");
232 UnitTest::Assert(
"3: cpu0.v0", cpu->GetVariable(
"v0")->ToString(),
"0xffffffff88880000");
233 UnitTest::Assert(
"3: cpu0.v1", cpu->GetVariable(
"v1")->ToString(),
"0xffffffffcccc0000");
235 cmd->
Execute(gxemul, dummyArguments);
238 UnitTest::Assert(
"2: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff80010100");
239 UnitTest::Assert(
"2: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007ed0");
241 UnitTest::Assert(
"2: cpu0.v1", cpu->GetVariable(
"v1")->ToString(),
"0xffffffffcccc0000");
243 cmd->
Execute(gxemul, dummyArguments);
246 UnitTest::Assert(
"1: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff800100fc");
247 UnitTest::Assert(
"1: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007ed0");
251 cmd->
Execute(gxemul, dummyArguments);
254 UnitTest::Assert(
"0: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff800100f8");
255 UnitTest::Assert(
"0: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007f00");
259 cmd->
Execute(gxemul, dummyArguments);
262 UnitTest::Assert(
"X: cpu0.pc", cpu->GetVariable(
"pc")->ToString(),
"0xffffffff800100f8");
263 UnitTest::Assert(
"X: cpu0.sp", cpu->GetVariable(
"sp")->ToString(),
"0xffffffffa0007f00");
270 UNITTEST(Test_BackwardStepCommand_AlreadyAtStep0);
271 UNITTEST(Test_BackwardStepCommand_NotWhenSnapshotsAreDisabled);
272 UNITTEST(Test_BackwardStepCommand_Basic);
273 UNITTEST(Test_BackwardStepCommand_ManualAddAndLoad);
A Command which sets the RunState to BackwardsSingleStepping.
virtual void ShowDebugMessage(const string &msg)=0
Shows a debug message.
virtual bool Execute(GXemul &gxemul, const vector< string > &arguments)
Executes the command on a given GXemul instance.
StateVariable * GetVariable(const string &name)
Gets a pointer to a state variable.
virtual string GetLongDescription() const
Returns a long description/help message for the command.
bool Reset()
Resets the emulation.
const refcount_ptr< Component > LightClone() const
Makes a light clone of the component and all its children.
bool RunCommand(const string &command, bool *pSuccess=NULL)
Runs a command, given as a string.
BackwardStepCommand()
Constructs a BackwardStepCommand.
uint64_t GetStep() const
Gets the current step of the emulation.
void SetSnapshottingEnabled(bool enabled)
Sets whether or not to use snapshots.
void DetectChanges(const refcount_ptr< Component > &oldClone, ostream &changeMessages) const
Compare an older clone to the current tree, to find changes.
#define UNITTESTS(class)
Helper for unit test case execution.
CommandInterpreter & GetCommandInterpreter()
Gets a reference to the CommandInterpreter.
virtual bool Execute(GXemul &gxemul, const vector< string > &arguments)=0
Executes the command on a given GXemul instance.
virtual string GetShortDescription() const
Returns a short (one-line) description of the command.
uint64_t ToInteger() const
Returns the variable as an unsignedinteger value.
StateVariables make up the persistent state of Component objects.
A Command is a named function, executed by the CommandInterpreter.
static void Assert(const string &strFailMessage, bool condition)
Asserts that a boolean condition is correct.
bool SetVariableValue(const string &name, const string &expression)
Sets a variable to a new value.
refcount_ptr< Component > GetRootComponent()
Gets a pointer to the root configuration component.
UI * GetUI()
Gets a pointer to the GXemul instance' active UI.
const refcount_ptr< Component > LookupPath(string path) const
Looks up a path from this Component, and returns a pointer to the found Component, if any.
void Execute(const int longestTotalRun=100000)
Run the emulation for "a while".
virtual ~BackwardStepCommand()
bool ParseFilenames(string templateMachine, int filenameCount, char *filenames[])
Parses command line arguments (file names).
#define UNITTEST(functionname)
Helper for unit test case execution.