OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
SimControlLanguageCommand Class Reference

#include <SimControlLanguageCommand.hh>

Inheritance diagram for SimControlLanguageCommand:
Inheritance graph
Collaboration diagram for SimControlLanguageCommand:
Collaboration graph

Public Member Functions

 SimControlLanguageCommand (const std::string &name)
 
virtual ~SimControlLanguageCommand ()
 
SimulatorFrontendsimulatorFrontend ()
 
const SimulatorFrontendsimulatorFrontendConst ()
 
virtual void printNextInstruction ()
 
virtual void printStopInformation ()
 
virtual void printStopReasons ()
 
virtual bool printBreakpointInfo (unsigned int breakpointHandle)
 
virtual void printSimulationTime ()
 
virtual std::ostream & outputStream ()
 
bool checkSimulationInitialized ()
 
bool checkSimulationNotAlreadyRunning ()
 
bool checkSimulationStopped ()
 
bool checkSimulationEnded ()
 
bool checkProgramLoaded ()
 
bool checkMachineLoaded ()
 
InstructionAddress parseInstructionAddressExpression (const std::string &expression)
 
TTAProgram::Address parseDataAddressExpression (const std::string &expression)
 
bool parseBreakpoint (const std::vector< DataObject > &arguments, Breakpoint &target)
 
bool askConditionFromUser (TclConditionScript &target)
 
bool askExpressionFromUser (ExpressionScript &target)
 
bool verifyBreakpointHandles (const std::vector< DataObject > &arguments, std::size_t startIndex=1)
 
void setErrorMessage (const TCEString &errorMsg)
 
- Public Member Functions inherited from CustomCommand
 CustomCommand (std::string name)
 
 CustomCommand (const CustomCommand &cmd)
 
virtual ~CustomCommand ()
 
std::string name () const
 
void setContext (InterpreterContext *context)
 
InterpreterContextcontext () const
 
void setInterpreter (ScriptInterpreter *si)
 
ScriptInterpreterinterpreter () const
 
virtual bool execute (const std::vector< DataObject > &arguments)=0
 
virtual std::string helpText () const =0
 
bool checkArgumentCount (int argumentCount, int minimum, int maximum)
 
bool checkIntegerArgument (const DataObject &argument)
 
bool checkPositiveIntegerArgument (const DataObject &argument)
 
bool checkUnsignedIntegerArgument (const DataObject &argument)
 
bool checkDoubleArgument (const DataObject &argument)
 

Protected Member Functions

bool setMemoryAddress (const std::string &addressString, std::string &addressSpaceName, std::size_t &memoryAddress)
 
bool setMemoryPointer (MemorySystem::MemoryPtr &memory, const std::string &addressSpaceName)
 

Detailed Description

This is a base class for Simulator Control Language commands.

Provides services command and useful for all Simulator Control Language commands.

Definition at line 63 of file SimControlLanguageCommand.hh.

Constructor & Destructor Documentation

◆ SimControlLanguageCommand()

SimControlLanguageCommand::SimControlLanguageCommand ( const std::string &  name)

Constructor.

Sets the name of the command to the base class.

Parameters
nameName of the command to add.

Definition at line 67 of file SimControlLanguageCommand.cc.

68 :
70}
std::string name() const

◆ ~SimControlLanguageCommand()

SimControlLanguageCommand::~SimControlLanguageCommand ( )
virtual

Destructor.

Does nothing.

Definition at line 77 of file SimControlLanguageCommand.cc.

77 {
78}

Member Function Documentation

◆ askConditionFromUser()

bool SimControlLanguageCommand::askConditionFromUser ( TclConditionScript target)

Prompts for a condition script from the user.

Also test runs the condition script. Returns false and sets interpreter error if the entered condition is illegal. If an empty condition script is entered, the condition script is set to always true "1" condition.

Parameters
targetThe target to put the condition script in.
Returns
false in case the script produces error when executed.

Definition at line 513 of file SimControlLanguageCommand.cc.

513 {
514
515 std::string conditionScript =
517 interpreter()->lineReader()->readLine(
520
521 if (StringTools::trim(conditionScript) == "") {
522 conditionScript = "1";
523 }
524
525 TclConditionScript testCondition(
526 dynamic_cast<TclInterpreter*>(interpreter()), conditionScript);
527
528 // try the condition
529 try {
530 testCondition.execute();
531 interpreter()->setResult("");
532 target = testCondition;
533 } catch (const ScriptExecutionFailure& sef) {
534 interpreter()->setError(true);
535 return false;
536 }
537 return true;
538}
ScriptInterpreter * interpreter() const
virtual void setError(bool state)
virtual void setResult(DataObject *result)
static SimulatorTextGenerator & textGenerator()
static std::string trim(const std::string &source)
@ TXT_INTERP_ENTER_CONDITION_PROMPT

References Script::execute(), CustomCommand::interpreter(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimulatorToolbox::textGenerator(), StringTools::trim(), and Texts::TXT_INTERP_ENTER_CONDITION_PROMPT.

Referenced by ConditionCommand::execute(), and parseBreakpoint().

Here is the call graph for this function:

◆ askExpressionFromUser()

bool SimControlLanguageCommand::askExpressionFromUser ( ExpressionScript target)

Prompts for an expression script from the user.

Also test runs the expression script. Returns false and sets interpreter error if the entered expression is illegal. If an empty expression script is entered, returns false and sets interpreter error.

Parameters
targetThe target to put the expression script in.
Returns
false in case the script produces error when executed or it's empty.

Definition at line 551 of file SimControlLanguageCommand.cc.

551 {
552
553 std::string expressionScript =
555 interpreter()->lineReader()->readLine(
558
559 if (StringTools::trim(expressionScript) == "") {
563 return false;
564 }
565
566 ExpressionScript testExpression(
567 dynamic_cast<TclInterpreter*>(interpreter()), expressionScript);
568
569 // try the condition
570 try {
571 testExpression.execute();
572 interpreter()->setResult("");
573 target = testExpression;
574 return true;
575 } catch (const ScriptExecutionFailure& sef) {
576 interpreter()->setError(true);
577 return false;
578 }
579}
@ TXT_INTERP_ENTER_EXPRESSION_PROMPT

References Script::execute(), CustomCommand::interpreter(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimulatorToolbox::textGenerator(), StringTools::trim(), Texts::TXT_EXPRESSION_EMPTY, and Texts::TXT_INTERP_ENTER_EXPRESSION_PROMPT.

Referenced by WatchCommand::execute().

Here is the call graph for this function:

◆ checkMachineLoaded()

bool SimControlLanguageCommand::checkMachineLoaded ( )

Checks that the simulated machine has been loaded successfully.

Returns
True if machine has been loaded.

Definition at line 199 of file SimControlLanguageCommand.cc.

199 {
200 if (!simulatorFrontend().isMachineLoaded()) {
201 interpreter()->setError(std::string("No machine loaded."));
202 return false;
203 }
204 return true;
205}

References CustomCommand::interpreter(), ScriptInterpreter::setError(), and simulatorFrontend().

Here is the call graph for this function:

◆ checkProgramLoaded()

bool SimControlLanguageCommand::checkProgramLoaded ( )

Checks that the simulated program has been loaded successfully.

Returns
True if program has been loaded.

Definition at line 180 of file SimControlLanguageCommand.cc.

180 {
181
182 if (!simulatorFrontend().isProgramLoaded()) {
186
187 return false;
188 }
189 return true;
190}

References CustomCommand::interpreter(), ScriptInterpreter::setError(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_NO_PROGRAM_LOADED.

Referenced by DisassembleCommand::execute(), MemDumpCommand::execute(), MemWriteCommand::execute(), and SymbolAddressCommand::execute().

Here is the call graph for this function:

◆ checkSimulationEnded()

bool SimControlLanguageCommand::checkSimulationEnded ( )

Checks that the simulation has ended.

Sets errors message and returns false if simulation has not ended.

Returns
True if simulation has ended.

Definition at line 158 of file SimControlLanguageCommand.cc.

158 {
159
160 DataObject* result = new DataObject();
161 if (!simulatorFrontend().hasSimulationEnded()) {
162 result->setString(
165 interpreter()->setResult(result);
166 return false;
167 }
168
169 interpreter()->setResult(result);
170 return true;
171}
virtual void setString(std::string value)
@ TXT_INTERP_SIMULATION_NOT_ENDED
Text to be printed when simulation has not ended and it should be.

References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_NOT_ENDED.

Referenced by KillCommand::execute().

Here is the call graph for this function:

◆ checkSimulationInitialized()

bool SimControlLanguageCommand::checkSimulationInitialized ( )

Checks that the simulation is initialized and ready to run.

Sets errors message and returns false if simulation is not initialized.

Returns
True if simulation is initialized.

Definition at line 88 of file SimControlLanguageCommand.cc.

88 {
89
90 DataObject* result = new DataObject();
91 if (!simulatorFrontend().isSimulationInitialized()) {
92 result->setString(
95 interpreter()->setResult(result);
96 return false;
97 }
98
99 interpreter()->setResult(result);
100 return true;
101}
@ TXT_INTERP_SIMULATION_NOT_INITIALIZED
Text to be printed when simulation is not initialized and it should be.

References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_NOT_INITIALIZED.

Referenced by ConditionCommand::execute(), DeleteBPCommand::execute(), DisableBPCommand::execute(), EnableBPCommand::execute(), IgnoreCommand::execute(), NextiCommand::execute(), RunCommand::execute(), StepiCommand::execute(), UntilCommand::execute(), and parseBreakpoint().

Here is the call graph for this function:

◆ checkSimulationNotAlreadyRunning()

bool SimControlLanguageCommand::checkSimulationNotAlreadyRunning ( )

Checks that the simulation is not already running.

Sets errors message and returns false if simulation is running.

Returns
True if simulation is not running.

Definition at line 111 of file SimControlLanguageCommand.cc.

111 {
112
113 DataObject* result = new DataObject();
114 if (simulatorFrontend().isSimulationRunning() ||
115 simulatorFrontend().isSimulationStopped()) {
116 result->setString(
119 interpreter()->setResult(result);
120 return false;
121 }
122 interpreter()->setResult(result);
123 return true;
124}
@ TXT_INTERP_SIMULATION_ALREDY_RUNNING
Text to be printed when simulation is already running and it should not be.

References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_ALREDY_RUNNING.

Referenced by RunCommand::execute().

Here is the call graph for this function:

◆ checkSimulationStopped()

bool SimControlLanguageCommand::checkSimulationStopped ( )

Checks that the simulation is stopped.

Sets errors message and returns false if simulation is not stopped by the user.

Returns
True if simulation is stopped.

Definition at line 135 of file SimControlLanguageCommand.cc.

135 {
136
137 DataObject* result = new DataObject();
138 if (!simulatorFrontend().isSimulationStopped()) {
139 result->setString(
142 interpreter()->setResult(result);
143 return false;
144 }
145
146 interpreter()->setResult(result);
147 return true;
148}
@ TXT_INTERP_SIMULATION_NOT_RUNNING
Text to be printed when simulation is not running and it should be.

References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_NOT_RUNNING.

Referenced by BackTraceCommand::execute(), ConditionCommand::execute(), DeleteBPCommand::execute(), DisableBPCommand::execute(), EnableBPCommand::execute(), IgnoreCommand::execute(), KillCommand::execute(), NextiCommand::execute(), ResumeCommand::execute(), StepiCommand::execute(), UntilCommand::execute(), and parseBreakpoint().

Here is the call graph for this function:

◆ outputStream()

std::ostream & SimControlLanguageCommand::outputStream ( )
virtual

Returns the output stream which can be used to print information to the user.

Uses the same output stream as the linereader to make the information texts printed to the same stream as confirmations of the linereader.

Returns
The output stream.

Definition at line 351 of file SimControlLanguageCommand.cc.

351 {
352 return interpreter()->lineReader()->outputStream();
353}
virtual std::ostream & outputStream()
virtual LineReader * lineReader() const

References CustomCommand::interpreter(), ScriptInterpreter::lineReader(), and LineReader::outputStream().

Referenced by BackTraceCommand::execute(), CommandsCommand::execute(), DisassembleCommand::execute(), HelpCommand::execute(), InfoProcCommand::execute(), InfoProgramCommand::execute(), ProgCommand::execute(), SettingCommand::execute(), printBreakpointInfo(), printNextInstruction(), printSimulationTime(), and printStopReasons().

Here is the call graph for this function:

◆ parseBreakpoint()

bool SimControlLanguageCommand::parseBreakpoint ( const std::vector< DataObject > &  arguments,
Breakpoint target 
)

Parses breakpoint data from the given arguments.

This is a refactoring of common functionality used in 'bp' and 'tbp' commands. Sets the error message to the interpreter and returns false if there was an error while parsing or simulation is in wrong state.

Parameters
argumentsas passed to the execute() of the command.
targetthe breakpoint instance to put the parsed data to.
Returns
true if the breakpoint was parsed succesfully.
Todo:
set the condition, if any

Definition at line 593 of file SimControlLanguageCommand.cc.

594 {
595
597 return false;
598 }
599
600 // how many arguments there are in the condition part
601 size_t conditionArgumentCount = 0;
602 for (size_t i = 0; i < arguments.size(); ++i) {
603 if (StringTools::stringToLower(arguments[i].stringValue()) ==
604 "if") {
605
606 if (i != arguments.size() - 1) {
610 return false;
611 }
612 conditionArgumentCount = 1;
613 break;
614 }
615 }
616
617 if (conditionArgumentCount > 0) {
618 TclConditionScript condition(NULL, "");
619 if (!askConditionFromUser(condition)) {
620 return false;
621 }
622 assert(condition.script().size() > 0);
623 if (condition.script().at(0) == "1") {
624 target.removeCondition();
625 } else {
626 target.setCondition(condition);
627 }
628 }
629
630 const int argumentsBeforeCondition =
631 arguments.size() - 1 - conditionArgumentCount;
632
633 InstructionAddress theAddress = 0;
634
635 if (argumentsBeforeCondition == 0 || argumentsBeforeCondition == 1) {
636
637 const std::string argument =
638 ((argumentsBeforeCondition == 0)?
639 (""):(arguments[1].stringValue()));
640 try {
641 theAddress =
643 } catch (const IllegalParameters&) {
644 // the helper function has set the error string to
645 // the interpreter
646 return false;
647 }
648
649 } else {
653 return false;
654 }
655
656 /// @todo set the condition, if any
657
658 target.setAddress(theAddress);
659 return true;
660}
#define assert(condition)
UInt32 InstructionAddress
Definition BaseType.hh:175
virtual void setAddress(InstructionAddress newAddress)
Definition Breakpoint.cc:96
InstructionAddress parseInstructionAddressExpression(const std::string &expression)
bool askConditionFromUser(TclConditionScript &target)
virtual void removeCondition()
Definition StopPoint.cc:142
virtual void setCondition(const ConditionScript &condition)
Definition StopPoint.cc:131
static std::string stringToLower(const std::string &source)
@ TXT_ILLEGAL_ARGUMENTS

References askConditionFromUser(), assert, checkSimulationInitialized(), checkSimulationStopped(), CustomCommand::interpreter(), parseInstructionAddressExpression(), StopPoint::removeCondition(), TclConditionScript::script(), Breakpoint::setAddress(), StopPoint::setCondition(), ScriptInterpreter::setError(), StringTools::stringToLower(), SimulatorToolbox::textGenerator(), and Texts::TXT_ILLEGAL_ARGUMENTS.

Referenced by BPCommand::execute(), and TBPCommand::execute().

Here is the call graph for this function:

◆ parseDataAddressExpression()

TTAProgram::Address SimControlLanguageCommand::parseDataAddressExpression ( const std::string &  expression)

Parses a data address expression string.

Expression string can be given by the user to, for example, 'x' command. Resolves symbol.

Supported address expression strings are currently:

*address An absolute address reference, can be an integer or a label string. In case of a label string, the return value contains also the address space of the address expression.

Parameters
expressionThe expression to parse.
Returns
The parsed instruction address and its address space, if given. In case address space could not be found, the address space field points to NullAddressSpace.
Exceptions
IllegalParameterswhen expression could not be parsed to an address.

Definition at line 471 of file SimControlLanguageCommand.cc.

472 {
473 std::string expr = StringTools::trim(expression);
474 const std::string errorMessage = "Illegal argument.";
475
476 InstructionAddress theAddress = 0;
477
478 // check if it's an integer, that is, a direct address reference
479 const std::string addressString = expression;
480 try {
481 theAddress = Conversion::toUnsignedInt(expression);
482 } catch (const NumberFormatException&) {
483 // it was not an integer, check if a label with given string
484 // is found in the global scope
485 const GlobalScope& globalScope =
487
488 try {
489 return globalScope.dataLabel(expression).address();
490 } catch (const KeyNotFound&) {
491 // couldn't evaluate the label
495 throw IllegalParameters(
496 __FILE__, __LINE__, __func__, errorMessage);
497 }
498 }
500}
#define __func__
static unsigned int toUnsignedInt(const T &source)
const TTAProgram::Program & program() const
static NullAddressSpace & instance()
virtual Address address() const
Definition Label.cc:84
const GlobalScope & globalScopeConst() const
Definition Program.cc:192
const DataLabel & dataLabel(const std::string &name) const
Definition Scope.cc:251

References __func__, TTAProgram::Label::address(), TTAProgram::Scope::dataLabel(), TTAProgram::Program::globalScopeConst(), TTAMachine::NullAddressSpace::instance(), CustomCommand::interpreter(), SimulatorFrontend::program(), ScriptInterpreter::setError(), simulatorFrontend(), SimulatorToolbox::textGenerator(), Conversion::toUnsignedInt(), StringTools::trim(), and Texts::TXT_LABEL_NOT_FOUND.

Referenced by setMemoryAddress().

Here is the call graph for this function:

◆ parseInstructionAddressExpression()

InstructionAddress SimControlLanguageCommand::parseInstructionAddressExpression ( const std::string &  expression)

Parses an instruction address expression string.

Expression string can be given by the user to, for example, 'break' or 'until' commands. This function also does range checking, when the address is lower than the first address of the program, it sets the address to the lowest address, when the address is bigger than the last address of the program, it sets the address to the last address.

Supported address expression strings are currently:

[empty] Address of the instruction following the current instruction. *address An absolute instruction address reference, can be an integer or a label string.

Parameters
expressionThe expression to parse.
Returns
The parsed instruction address.
Exceptions
IllegalParameterswhen expression could not be parsed to an address.

Definition at line 378 of file SimControlLanguageCommand.cc.

379 {
380 std::string expr = StringTools::trim(expression);
381 const std::string errorMessage = "Illegal argument.";
382
383 InstructionAddress theAddress = 0;
384 if (expr.size() == 0) {
385 theAddress = simulatorFrontend().programCounter() + 1;
386 } else {
387 // the argument is an absolute address, try to evaluate it to an
388 // instruction address
389
390 // check if it's an integer, that is, a direct instruction address
391 // reference
392 const std::string address = expression;
393 try {
394 theAddress = Conversion::toUnsignedInt(address);
395 } catch (const NumberFormatException&) {
396 // check if a label with given string is found in the
397 // global scope
398 const GlobalScope& globalScope =
400
401 try {
402 theAddress =
403 globalScope.codeLabel(address).address().location();
404 } catch (const KeyNotFound&) {
405 try {
406 // check if it's a reference to a function
407 theAddress =
409 startAddress().location();
410 } catch (const KeyNotFound&) {
411 try {
412 // check if user forgot the leading "_"
413 theAddress =
415 std::string("_") + address).
416 startAddress().location();
417 } catch (const KeyNotFound&) {
418 // couldn't evaluate the label
422
423 throw IllegalParameters(
424 __FILE__, __LINE__, __func__, errorMessage);
425 }
426 }
427 }
428 }
429 }
430
431 // check the boundaries of the instruction address and fix it, if necessary
432 const InstructionAddress programLastAddress =
434 - 1;
435
436 const InstructionAddress programFirstAddress =
438 location();
439
440 if (theAddress > programLastAddress) {
441 theAddress = programLastAddress;
442 } else if (theAddress < programFirstAddress) {
443 theAddress = programFirstAddress;
444 }
445
446 return theAddress;
447}
InstructionAddress programCounter() const
InstructionAddress location() const
virtual Address address() const
Definition CodeLabel.cc:101
virtual Address endAddress() const
virtual Address startAddress() const
Procedure & procedure(int index) const
Definition Program.cc:622
Procedure & lastProcedure() const
Definition Program.cc:230
Procedure & firstProcedure() const
Definition Program.cc:213
const CodeLabel & codeLabel(const std::string &name) const
Definition Scope.cc:233

References __func__, TTAProgram::CodeLabel::address(), TTAProgram::Scope::codeLabel(), TTAProgram::CodeSnippet::endAddress(), TTAProgram::Program::firstProcedure(), TTAProgram::Program::globalScopeConst(), CustomCommand::interpreter(), TTAProgram::Program::lastProcedure(), TTAProgram::Address::location(), TTAProgram::Program::procedure(), SimulatorFrontend::program(), SimulatorFrontend::programCounter(), ScriptInterpreter::setError(), simulatorFrontend(), TTAProgram::CodeSnippet::startAddress(), SimulatorToolbox::textGenerator(), Conversion::toUnsignedInt(), StringTools::trim(), and Texts::TXT_LABEL_NOT_FOUND.

Referenced by DisassembleCommand::execute(), UntilCommand::execute(), and parseBreakpoint().

Here is the call graph for this function:

◆ printBreakpointInfo()

bool SimControlLanguageCommand::printBreakpointInfo ( unsigned int  breakpointHandle)
virtual

Prints information of a breakpoint.

If breakpoint with the given handle could not be found, sets error to the interpreter and returns false.

Parameters
breakpointHandleThe handle of the breakpoint to be printed.
Returns
true If breakpoint could be printed.

Definition at line 678 of file SimControlLanguageCommand.cc.

679 {
680
681 try {
682 const StopPoint& stopPoint =
684 breakpointHandle);
685
686 outputStream()
687 << std::right << std::setw(BPINFO_HANDLE_COL_WIDTH)
688 << breakpointHandle << ": " << stopPoint.description()
689 << std::endl;
690
691 return true;
692 } catch (const InstanceNotFound&) {
696 return false;
697 }
698}
const int BPINFO_HANDLE_COL_WIDTH
widths of the columns of the break point info table widths don't include the spaces between columns t...
virtual std::ostream & outputStream()
StopPointManager & stopPointManager()
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
virtual std::string description() const =0
Definition StopPoint.cc:239

References BPINFO_HANDLE_COL_WIDTH, StopPoint::description(), CustomCommand::interpreter(), outputStream(), ScriptInterpreter::setError(), simulatorFrontend(), SimulatorFrontend::stopPointManager(), StopPointManager::stopPointWithHandleConst(), SimulatorToolbox::textGenerator(), and Texts::TXT_BREAKPOINT_NOT_FOUND.

Referenced by BPCommand::execute(), ConditionCommand::execute(), DisableBPCommand::execute(), EnableBPCommand::execute(), IgnoreCommand::execute(), InfoBreakpointsCommand::execute(), TBPCommand::execute(), and WatchCommand::execute().

Here is the call graph for this function:

◆ printNextInstruction()

void SimControlLanguageCommand::printNextInstruction ( )
virtual

Prints the next simulated instruction to the simulator console.

Definition at line 228 of file SimControlLanguageCommand.cc.

228 {
229
230 if (simulatorFrontend().nextInstructionPrinting())
232 << std::endl;
233}
std::string programLocationDescription() const

References outputStream(), SimulatorFrontend::programLocationDescription(), and simulatorFrontend().

Referenced by NextiCommand::execute(), StepiCommand::execute(), UntilCommand::execute(), and printStopInformation().

Here is the call graph for this function:

◆ printSimulationTime()

void SimControlLanguageCommand::printSimulationTime ( )
virtual

Prints the simulation time in minutes and seconds in case it's enabled.

Also prints out the frequency in MHz

Definition at line 322 of file SimControlLanguageCommand.cc.

322 {
323
324 if (!simulatorFrontend().simulationTimeStatistics())
325 return;
326
328 double time = simulatorFrontend().lastRunTime();
329
330 double minutes = 0.0;
331 double seconds = modf(time / 60.0 , &minutes) * 60.0;
332 double frequency = (static_cast<double>(cycleCount) / time) / 1000000;
333
334
335 outputStream()
336 << minutes << " min "
337 << seconds << " s "
338 << frequency << " MHz" << std::endl;
339}
CycleCount ClockCycleCount
Alias for ClockCycleCount.
double lastRunTime() const
CycleCount lastRunCycleCount() const

References SimulatorFrontend::lastRunCycleCount(), SimulatorFrontend::lastRunTime(), outputStream(), and simulatorFrontend().

Referenced by StepiCommand::execute(), UntilCommand::execute(), and printStopInformation().

Here is the call graph for this function:

◆ printStopInformation()

void SimControlLanguageCommand::printStopInformation ( )
virtual

Prints information that should be printed after simulation is stopped.

These should be printed when the control is returned back to user after running simulation with "run" or "resume" commands and being stopped due to simulation finish or a breakpoint.

Definition at line 243 of file SimControlLanguageCommand.cc.

References printNextInstruction(), printSimulationTime(), and printStopReasons().

Referenced by ResumeCommand::execute(), and RunCommand::execute().

Here is the call graph for this function:

◆ printStopReasons()

void SimControlLanguageCommand::printStopReasons ( )
virtual

Prints the reasons why simulation has been stopped.

Todo:
the stop reason code to string conversion should be externalized to another function.

Definition at line 257 of file SimControlLanguageCommand.cc.

257 {
258 for (unsigned int i = 0; i < simulatorFrontend().stopReasonCount(); ++i) {
259 switch (simulatorFrontend().stopReason(i)) {
261 outputStream()
263 Texts::TXT_STOPREASON_STEPPING).str() << std::endl;
264 break;
265 case SRE_AFTER_UNTIL:
266 outputStream()
268 Texts::TXT_STOPREASON_UNTIL).str() << std::endl;
269 break;
273 Texts::TXT_STOPREASON_TIMEOUT).str() << std::endl;
274 break;
276 outputStream()
278 Texts::TXT_STOPREASON_USERREQUEST).str() << std::endl;
279 break;
281 outputStream()
283 Texts::TXT_STOPREASON_RUNTIME_ERROR).str() << std::endl;
284 break;
285 case SRE_BREAKPOINT: {
286 StopPointManager& stopPointManager =
288 for (unsigned int i = 0;
289 i < stopPointManager.stopCausingStopPointCount(); ++i) {
290 try {
291 // test that the breakpoint is not deleted
292 stopPointManager.stopPointWithHandleConst(
293 stopPointManager.stopCausingStopPoint(i));
294 outputStream()
297 stopPointManager.stopCausingStopPoint(i)).str()
298 << std::endl;
299 } catch (const InstanceNotFound&) {
300 outputStream()
303 << std::endl;
304 }
305 }
306 break;
307 }
308 default:
309 outputStream()
310 << "Stopped because of an unknown reason." << std::endl;
311 break;
312 }
313 }
314}
@ SRE_AFTER_TIMEOUT
Stopped after simulation timeout instruction.
@ SRE_BREAKPOINT
Stopped because of at least one breakpoint.
@ SRE_USER_REQUESTED
User requested the simulation to stop explicitly, e.g., by pressing ctrl-c in the CLI.
@ SRE_AFTER_UNTIL
Stopped after running to the wanted.
@ SRE_AFTER_STEPPING
Stopped after stepping the given count.
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
unsigned int stopReasonCount() const
StopReason stopReason(unsigned int index) const
unsigned int stopCausingStopPointCount() const
unsigned int stopCausingStopPoint(unsigned int index) const
virtual boost::format text(int textId)
@ TXT_STOPREASON_TIMEOUT
Stop reason: timeout
@ TXT_STOPREASON_STEPPING
Stop reason: stepping.
@ TXT_STOPREASON_USERREQUEST
Stop reason: user requested.
@ TXT_STOPREASON_RUNTIME_ERROR
Stop reason: user requested.
@ TXT_STOPREASON_DELETED_BREAKPOINT
Stop reason: temporary breakpoint.
@ TXT_STOPREASON_UNTIL
Stop reason: until.
@ TXT_STOPREASON_BREAKPOINT
Stop reason: breakpoint.

References outputStream(), simulatorFrontend(), SRE_AFTER_STEPPING, SRE_AFTER_TIMEOUT, SRE_AFTER_UNTIL, SRE_BREAKPOINT, SRE_RUNTIME_ERROR, SRE_USER_REQUESTED, StopPointManager::stopCausingStopPoint(), StopPointManager::stopCausingStopPointCount(), SimulatorFrontend::stopPointManager(), StopPointManager::stopPointWithHandleConst(), SimulatorFrontend::stopReason(), SimulatorFrontend::stopReasonCount(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_STOPREASON_BREAKPOINT, Texts::TXT_STOPREASON_DELETED_BREAKPOINT, Texts::TXT_STOPREASON_RUNTIME_ERROR, Texts::TXT_STOPREASON_STEPPING, Texts::TXT_STOPREASON_TIMEOUT, Texts::TXT_STOPREASON_UNTIL, and Texts::TXT_STOPREASON_USERREQUEST.

Referenced by InfoProgramCommand::execute(), and printStopInformation().

Here is the call graph for this function:

◆ setErrorMessage()

void SimControlLanguageCommand::setErrorMessage ( const TCEString errorMsg)

Definition at line 738 of file SimControlLanguageCommand.cc.

738 {
739 DataObject* errorMessage = new DataObject();
740 errorMessage->setString(errorMsg);
741 interpreter()->setResult(errorMessage);
742}

References CustomCommand::interpreter(), ScriptInterpreter::setResult(), and DataObject::setString().

Referenced by BackTraceCommand::execute().

Here is the call graph for this function:

◆ setMemoryAddress()

bool SimControlLanguageCommand::setMemoryAddress ( const std::string &  addressString,
std::string &  addressSpaceName,
std::size_t &  memoryAddress 
)
protected

Parses the address string to corresponding memory address and address space.

Parameters
addressStringMemory address command string to parse.
addressSpaceNameAddress space name to be set.
memoryAddressMemory address to be set.
Returns
true on success.

Definition at line 753 of file SimControlLanguageCommand.cc.

756 {
757
758 try {
759 const TTAProgram::Address& parsedAddress =
760 parseDataAddressExpression(addressString);
761 if (&parsedAddress.space() !=
763 addressSpaceName = parsedAddress.space().name();
764 }
765 memoryAddress = parsedAddress.location();
766 } catch(const IllegalParameters& n) {
767 return false;
768 }
769 return true;
770}
TTAProgram::Address parseDataAddressExpression(const std::string &expression)
virtual TCEString name() const
const TTAMachine::AddressSpace & space() const

References TTAMachine::NullAddressSpace::instance(), TTAProgram::Address::location(), TTAMachine::Component::name(), parseDataAddressExpression(), and TTAProgram::Address::space().

Referenced by MemDumpCommand::execute(), and MemWriteCommand::execute().

Here is the call graph for this function:

◆ setMemoryPointer()

bool SimControlLanguageCommand::setMemoryPointer ( MemorySystem::MemoryPtr memory,
const std::string &  addressSpaceName 
)
protected

Sets memory instance from a given AddressSpaceName to given memory.

Parameters
memoryMemory pointer to be set
addressSpaceNameThe name of the address space.
Returns
true on success.

must have the address space defined

Definition at line 780 of file SimControlLanguageCommand.cc.

782 {
783
784 if (simulatorFrontend().memorySystem().memoryCount() < 1) {
788 return false;
789 } else if (simulatorFrontend().memorySystem().memoryCount() == 1) {
790 memory = simulatorFrontend().memorySystem().memory(0);
791 } else {
792 /// must have the address space defined
793 if (addressSpaceName == "") {
797 return false;
798 }
799 try {
800 memory =
801 simulatorFrontend().memorySystem().memory(addressSpaceName);
802 } catch (const InstanceNotFound&) {
806 return false;
807 }
808 }
809 return true;
810}
MemoryPtr memory(const TTAMachine::AddressSpace &as)
MemorySystem & memorySystem(int coreId=-1)

References CustomCommand::interpreter(), MemorySystem::memory(), SimulatorFrontend::memorySystem(), ScriptInterpreter::setError(), simulatorFrontend(), SimulatorToolbox::textGenerator(), Texts::TXT_ADDRESS_SPACE_NOT_FOUND, and Texts::TXT_NO_ADDRESS_SPACE_GIVEN.

Referenced by MemDumpCommand::execute(), and MemWriteCommand::execute().

Here is the call graph for this function:

◆ simulatorFrontend()

SimulatorFrontend & SimControlLanguageCommand::simulatorFrontend ( )

Returns the SimulatorFrontend instance stored in the context.

Returns
The SimulatorFrontend instance.

Definition at line 214 of file SimControlLanguageCommand.cc.

214 {
215
216 assert(interpreter() != NULL);
217
218 SimulatorInterpreterContext& interpreterContext =
220
221 return interpreterContext.simulatorFrontend();
222}
virtual InterpreterContext & context() const =0

References assert, ScriptInterpreter::context(), CustomCommand::interpreter(), and SimulatorInterpreterContext::simulatorFrontend().

Referenced by checkMachineLoaded(), checkProgramLoaded(), checkSimulationEnded(), checkSimulationInitialized(), checkSimulationNotAlreadyRunning(), checkSimulationStopped(), BackTraceCommand::execute(), BPCommand::execute(), ConditionCommand::execute(), DeleteBPCommand::execute(), DisableBPCommand::execute(), EnableBPCommand::execute(), IgnoreCommand::execute(), InfoRegistersCommand::execute(), InfoImmediatesCommand::execute(), InfoRegFilesCommand::execute(), InfoIunitsCommand::execute(), InfoBussesCommand::execute(), InfoPortsCommand::execute(), InfoSegmentsCommand::execute(), InfoFunitsCommand::execute(), InfoProcCommand::execute(), InfoStatsCommand::execute(), InfoProgramCommand::execute(), InfoBreakpointsCommand::execute(), KillCommand::execute(), MemDumpCommand::execute(), NextiCommand::execute(), ProgCommand::execute(), ResumeCommand::execute(), RunCommand::execute(), SettingCommand::execute(), StepiCommand::execute(), SymbolAddressCommand::execute(), TBPCommand::execute(), UntilCommand::execute(), WatchCommand::execute(), parseDataAddressExpression(), parseInstructionAddressExpression(), printBreakpointInfo(), printNextInstruction(), printSimulationTime(), printStopReasons(), setMemoryPointer(), and verifyBreakpointHandles().

Here is the call graph for this function:

◆ simulatorFrontendConst()

const SimulatorFrontend & SimControlLanguageCommand::simulatorFrontendConst ( )

◆ verifyBreakpointHandles()

bool SimControlLanguageCommand::verifyBreakpointHandles ( const std::vector< DataObject > &  arguments,
std::size_t  startIndex = 1 
)

Verifies that the list of breakpoint ids are valid breakpoint handles.

A refactoring for error checking of the {enable,disable,delete}bp commands. Sets interpreter error in case invalid handles are found and returns false.

Parameters
argumentsThe arguments as given to the execute() of the command.
startIndexThe first argument to check.
Returns
true if all handles are valid.

Definition at line 712 of file SimControlLanguageCommand.cc.

714 {
715
716 // verify that the breakpoints are found
717 for (size_t i = startIndex; i < arguments.size(); ++i) {
718 if (!checkPositiveIntegerArgument(arguments[i])) {
719 return false;
720 }
721 const unsigned int breakpointHandle = arguments[i].integerValue();
722 try {
723 StopPointManager& stopPointManager =
725 // just check that breakpoint is found with the handle
726 stopPointManager.stopPointWithHandleConst(breakpointHandle);
727 } catch (const InstanceNotFound&) {
731 return false;
732 }
733 }
734 return true;
735}
bool checkPositiveIntegerArgument(const DataObject &argument)

References CustomCommand::checkPositiveIntegerArgument(), CustomCommand::interpreter(), ScriptInterpreter::setError(), simulatorFrontend(), SimulatorFrontend::stopPointManager(), StopPointManager::stopPointWithHandleConst(), SimulatorToolbox::textGenerator(), and Texts::TXT_BREAKPOINT_NOT_FOUND.

Referenced by DeleteBPCommand::execute(), DisableBPCommand::execute(), and EnableBPCommand::execute().

Here is the call graph for this function:

The documentation for this class was generated from the following files: