OpenASIP  2.0
Public Member Functions | List of all members
ConditionCommand Class Reference

#include <ConditionCommand.hh>

Inheritance diagram for ConditionCommand:
Inheritance graph
Collaboration diagram for ConditionCommand:
Collaboration graph

Public Member Functions

 ConditionCommand ()
 
virtual ~ConditionCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
virtual std::string helpText () const
 
- Public Member Functions inherited from SimControlLanguageCommand
 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
 
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)
 

Additional Inherited Members

- Protected Member Functions inherited from SimControlLanguageCommand
bool setMemoryAddress (const std::string &addressString, std::string &addressSpaceName, std::size_t &memoryAddress)
 
bool setMemoryPointer (MemorySystem::MemoryPtr &memory, const std::string &addressSpaceName)
 

Detailed Description

Implementation of the "condition" command of the Simulator Control Language.

Definition at line 47 of file ConditionCommand.hh.

Constructor & Destructor Documentation

◆ ConditionCommand()

ConditionCommand::ConditionCommand ( )

Constructor.

Sets the name of the command to the base class.

Definition at line 52 of file ConditionCommand.cc.

52  :
53  SimControlLanguageCommand("condition") {
54 }

◆ ~ConditionCommand()

ConditionCommand::~ConditionCommand ( )
virtual

Destructor.

Does nothing.

Definition at line 61 of file ConditionCommand.cc.

61  {
62 }

Member Function Documentation

◆ execute()

bool ConditionCommand::execute ( const std::vector< DataObject > &  arguments)
virtual

Executes the "condition" command.

Modifies conditions of breakpoints.

Parameters
argumentsThe handle of the breakpoint of which condition to modify.
Returns
True in case simulation is initialized and arguments are ok.
Exceptions
NumberFormatExceptionIs never thrown by this command.
Todo:
Use the count for the step.

Implements CustomCommand.

Definition at line 75 of file ConditionCommand.cc.

75  {
76  if (!checkArgumentCount(arguments.size() - 1, 1, 1)) {
77  return false;
78  }
79 
80  if (!checkSimulationStopped()) {
82  return false;
83  }
84  }
85 
86  if (arguments.size() == 2) {
87  if (!checkIntegerArgument(arguments[1])) {
88  return false;
89  }
90  const int breakpointHandle = arguments[1].integerValue();
91  try {
92  StopPointManager& stopPointManager =
94  stopPointManager.stopPointWithHandleConst(breakpointHandle);
95 
96  TclConditionScript condition(NULL, "");
97  if (!askConditionFromUser(condition)) {
98  return false;
99  }
100  assert(condition.script().size() > 0);
101  if (condition.script().at(0) == "1") {
102  stopPointManager.removeCondition(breakpointHandle);
103  } else {
104  stopPointManager.setCondition(breakpointHandle, condition);
105  }
106  printBreakpointInfo(breakpointHandle);
107  } catch (const InstanceNotFound&) {
111  return false;
112  }
113 
114 
115  }
116  return true;
117 }

References SimControlLanguageCommand::askConditionFromUser(), assert, CustomCommand::checkArgumentCount(), CustomCommand::checkIntegerArgument(), SimControlLanguageCommand::checkSimulationInitialized(), SimControlLanguageCommand::checkSimulationStopped(), CustomCommand::interpreter(), SimControlLanguageCommand::printBreakpointInfo(), StopPointManager::removeCondition(), TclConditionScript::script(), StopPointManager::setCondition(), ScriptInterpreter::setError(), SimControlLanguageCommand::simulatorFrontend(), SimulatorFrontend::stopPointManager(), StopPointManager::stopPointWithHandleConst(), SimulatorToolbox::textGenerator(), and Texts::TXT_BREAKPOINT_NOT_FOUND.

Here is the call graph for this function:

◆ helpText()

std::string ConditionCommand::helpText ( ) const
virtual

Returns the help text for this command.

Help text is searched from SimulatorTextGenerator.

Returns
The help text.
Todo:
Use SimulatorTextGenerator to get the help text.

Implements CustomCommand.

Definition at line 128 of file ConditionCommand.cc.

128  {
131 }

References Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_HELP_CONDITION.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
CustomCommand::checkArgumentCount
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
Definition: CustomCommand.cc:82
Texts::TXT_BREAKPOINT_NOT_FOUND
@ TXT_BREAKPOINT_NOT_FOUND
Definition: SimulatorTextGenerator.hh:186
SimControlLanguageCommand::checkSimulationStopped
bool checkSimulationStopped()
Definition: SimControlLanguageCommand.cc:135
TclConditionScript
Definition: TclConditionScript.hh:50
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
StopPointManager::setCondition
void setCondition(unsigned int handle, const ConditionScript &condition)
Definition: StopPointManager.cc:296
Texts::TXT_INTERP_HELP_CONDITION
@ TXT_INTERP_HELP_CONDITION
Help text for command "condition" of the CLI.
Definition: SimulatorTextGenerator.hh:91
assert
#define assert(condition)
Definition: Application.hh:86
CustomCommand::checkIntegerArgument
bool checkIntegerArgument(const DataObject &argument)
Definition: CustomCommand.cc:110
SimControlLanguageCommand::SimControlLanguageCommand
SimControlLanguageCommand(const std::string &name)
Definition: SimControlLanguageCommand.cc:67
StopPointManager::stopPointWithHandleConst
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
Definition: StopPointManager.cc:248
SimControlLanguageCommand::askConditionFromUser
bool askConditionFromUser(TclConditionScript &target)
Definition: SimControlLanguageCommand.cc:513
StopPointManager
Definition: StopPointManager.hh:50
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
SimControlLanguageCommand::checkSimulationInitialized
bool checkSimulationInitialized()
Definition: SimControlLanguageCommand.cc:88
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
StopPointManager::removeCondition
void removeCondition(unsigned int handle)
Definition: StopPointManager.cc:308
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
SimulatorFrontend::stopPointManager
StopPointManager & stopPointManager()
Definition: SimulatorFrontend.cc:2108
InstanceNotFound
Definition: Exception.hh:304
SimControlLanguageCommand::printBreakpointInfo
virtual bool printBreakpointInfo(unsigned int breakpointHandle)
Definition: SimControlLanguageCommand.cc:678