OpenASIP  2.0
Classes | Public Member Functions | Protected Types | Protected Attributes | List of all members
SettingCommand Class Reference

#include <SettingCommand.hh>

Inheritance diagram for SettingCommand:
Inheritance graph
Collaboration diagram for SettingCommand:
Collaboration graph

Classes

class  SimulatorSetting
 

Public Member Functions

 SettingCommand ()
 
virtual ~SettingCommand ()
 
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)
 

Protected Types

typedef std::map< std::string, SimulatorSetting * > SettingMap
 container for simulator settings indexed by name More...
 

Protected Attributes

SettingMap settings_
 storage for simulator settings More...
 

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 "setting" command of the Simulator Control Language.

Definition at line 51 of file SettingCommand.hh.

Member Typedef Documentation

◆ SettingMap

typedef std::map<std::string, SimulatorSetting*> SettingCommand::SettingMap
protected

container for simulator settings indexed by name

Definition at line 78 of file SettingCommand.hh.

Constructor & Destructor Documentation

◆ SettingCommand()

SettingCommand::SettingCommand ( )

Definition at line 666 of file SettingCommand.cc.

666  :
667  SimControlLanguageCommand("setting") {
668 
669  settings_["execution_trace"] =
670  new TemplatedSimulatorSetting<BooleanSetting, SetExecutionTrace>(
673 
674  settings_["bus_trace"] =
675  new TemplatedSimulatorSetting<BooleanSetting, SetBusTrace>(
678 
679  settings_["rf_tracking"] =
680  new TemplatedSimulatorSetting<BooleanSetting, SetRFTracking>(
683 
684  settings_["history_filename"] =
685  new TemplatedSimulatorSetting<StringSetting, SetHistoryFilename>(
688 
689  settings_["history_save"] =
690  new TemplatedSimulatorSetting<BooleanSetting, SetHistorySave>(
693 
694  settings_["history_size"] =
695  new TemplatedSimulatorSetting<PositiveIntegerSetting, SetHistorySize>(
698 
699  settings_["procedure_transfer_tracking"] =
700  new TemplatedSimulatorSetting<
701  BooleanSetting, SetProcedureTransferTracing>(
704  str());
705 
706  settings_["memory_access_tracking"] =
707  new TemplatedSimulatorSetting<
708  BooleanSetting, SetMemoryAccessTracking>(
711  str());
712 
713  settings_["utilization_data_saving"] =
714  new TemplatedSimulatorSetting<
715  BooleanSetting, SetUtilizationSaving>(
718  str());
719 
720  settings_["profile_data_saving"] =
721  new TemplatedSimulatorSetting<
722  BooleanSetting, SetProfileSaving>(
725  str());
726 
727  settings_["fu_conflict_detection"] =
728  new TemplatedSimulatorSetting<
729  BooleanSetting, SetFUConflictDetection>(
732  str());
733 
734  settings_["next_instruction_printing"] =
735  new TemplatedSimulatorSetting<
736  BooleanSetting, SetNextInstructionPrinting>(
739  str());
740 
741  settings_["simulation_time_statistics"] =
742  new TemplatedSimulatorSetting<
743  BooleanSetting, SetSimulationTimeStatistics>(
746 
747  settings_["simulation_timeout"] =
748  new TemplatedSimulatorSetting<
749  PositiveIntegerSetting, SetSimulationTimeout>(
752 
753  settings_["static_compilation"] =
754  new TemplatedSimulatorSetting<
755  BooleanSetting, SetStaticCompilation>(
758 
759  settings_["call_history_length"] =
760  new TemplatedSimulatorSetting<
761  PositiveIntegerSetting, SetCallHistoryLength>(
762  "Sets the length of last procedure transfers to save in\n"
763  "memory for call trace printing.");
764 }

References settings_, Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_INTERP_SETTING_BUSTRACE, Texts::TXT_INTERP_SETTING_EXECTRACE, Texts::TXT_INTERP_SETTING_FU_CONFLICT_DETECTION, Texts::TXT_INTERP_SETTING_HISTORY_FILENAME, Texts::TXT_INTERP_SETTING_HISTORY_SAVE, Texts::TXT_INTERP_SETTING_HISTORY_SIZE, Texts::TXT_INTERP_SETTING_MEMORY_ACCESS_TRACKING, Texts::TXT_INTERP_SETTING_NEXT_INSTRUCTION_PRINTING, Texts::TXT_INTERP_SETTING_PROCEDURE_TRANSFER_TRACKING, Texts::TXT_INTERP_SETTING_PROFILE_SAVING, Texts::TXT_INTERP_SETTING_RFTRACKING, Texts::TXT_INTERP_SETTING_UTILIZATION_SAVING, Texts::TXT_SIMULATION_TIME_STATISTICS, Texts::TXT_SIMULATION_TIMEOUT, and Texts::TXT_STATIC_COMPILATION.

Here is the call graph for this function:

◆ ~SettingCommand()

SettingCommand::~SettingCommand ( )
virtual

Destructor.

Does nothing.

Definition at line 771 of file SettingCommand.cc.

771  {
773 }

References MapTools::deleteAllValues(), and settings_.

Here is the call graph for this function:

Member Function Documentation

◆ execute()

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

Executes the "setting" command.

Command that allows changing and listing simulator's settings. If no arguments are given, all simulator settings are listed in predefined oreder. If one argument is given, it's expected to be a simulator setting, of which current value is printed. If two arguments are given, the first argument tells the name of the setting to modify, and second argument the new value.

Parameters
argumentsRead the comment.
Returns
True in case arguments are ok.
Exceptions
NumberFormatExceptionIs never thrown by this command.
Todo:
Use the count for the step.

Implements CustomCommand.

Definition at line 791 of file SettingCommand.cc.

791  {
792  const int argumentCount = arguments.size() -1;
793 
794  if (!checkArgumentCount(argumentCount, 0, 2)) {
795  return false;
796  }
797 
798  // no arguments given, list all the settings and their values,
799  // value types and explanations
800  if (argumentCount == 0) {
801  SettingMap::iterator i = settings_.begin();
802 
803  while (i != settings_.end()) {
804  outputStream().flags(std::ios_base::left);
805  outputStream()
806  << std::setw(30) << (*i).first
807  << std::setw(20) << (*i).second->valueAsString() << " "
808  << (*i).second->description() << std::endl;
809  ++i;
810  }
811  return true;
812  }
813 
814  SettingMap::iterator settingPosition =
815  settings_.find(
816  StringTools::stringToLower(arguments.at(1).stringValue()));
817  if (settingPosition == settings_.end()) {
821  return false;
822  }
823 
824  SimulatorSetting& setting = *((*settingPosition).second);
825 
826  // two arguments given, modify the setting
827  if (arguments.size() - 1 == 2) {
828  try {
829  if (!setting.setValue(
830  *dynamic_cast<SimulatorInterpreter*>(interpreter()),
831  simulatorFrontend(), arguments.at(2))) {
832  return false;
833  }
834  } catch (const Exception& e) {
836  return false;
837  }
838  }
839 
840  DataObject* result = new DataObject();
841  result->setString(setting.valueAsString());
842  interpreter()->setResult(result);
843  return true;
844 }

References CustomCommand::checkArgumentCount(), Exception::errorMessage(), CustomCommand::interpreter(), SimControlLanguageCommand::outputStream(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), DataObject::setString(), settings_, SettingCommand::SimulatorSetting::setValue(), SimControlLanguageCommand::simulatorFrontend(), StringTools::stringToLower(), SimulatorToolbox::textGenerator(), Texts::TXT_NO_SUCH_SETTING, and SettingCommand::SimulatorSetting::valueAsString().

Here is the call graph for this function:

◆ helpText()

std::string SettingCommand::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 855 of file SettingCommand.cc.

855  {
858 }

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

Here is the call graph for this function:

Member Data Documentation

◆ settings_

SettingMap SettingCommand::settings_
protected

storage for simulator settings

Definition at line 80 of file SettingCommand.hh.

Referenced by CompiledSimSettingCommand::CompiledSimSettingCommand(), execute(), SettingCommand(), and ~SettingCommand().


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
SetStaticCompilation
Definition: SettingCommand.cc:362
SimControlLanguageCommand::outputStream
virtual std::ostream & outputStream()
Definition: SimControlLanguageCommand.cc:351
Texts::TXT_INTERP_SETTING_MEMORY_ACCESS_TRACKING
@ TXT_INTERP_SETTING_MEMORY_ACCESS_TRACKING
Definition: SimulatorTextGenerator.hh:199
DataObject
Definition: DataObject.hh:50
Texts::TXT_INTERP_SETTING_NEXT_INSTRUCTION_PRINTING
@ TXT_INTERP_SETTING_NEXT_INSTRUCTION_PRINTING
Definition: SimulatorTextGenerator.hh:149
Texts::TXT_INTERP_SETTING_RFTRACKING
@ TXT_INTERP_SETTING_RFTRACKING
Definition: SimulatorTextGenerator.hh:147
MapTools::deleteAllValues
static void deleteAllValues(MapType &aMap)
Texts::TXT_INTERP_SETTING_PROCEDURE_TRANSFER_TRACKING
@ TXT_INTERP_SETTING_PROCEDURE_TRANSFER_TRACKING
Definition: SimulatorTextGenerator.hh:198
SetProfileSaving
Definition: SettingCommand.cc:165
Texts::TXT_INTERP_SETTING_HISTORY_SAVE
@ TXT_INTERP_SETTING_HISTORY_SAVE
Definition: SimulatorTextGenerator.hh:150
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
Texts::TXT_STATIC_COMPILATION
@ TXT_STATIC_COMPILATION
Use static compilation when using compiled simulator.
Definition: SimulatorTextGenerator.hh:158
Texts::TXT_INTERP_SETTING_BUSTRACE
@ TXT_INTERP_SETTING_BUSTRACE
Definition: SimulatorTextGenerator.hh:146
Texts::TXT_NO_SUCH_SETTING
@ TXT_NO_SUCH_SETTING
Definition: TextGenerator.hh:63
SetCallHistoryLength
Definition: SettingCommand.cc:647
SimControlLanguageCommand::SimControlLanguageCommand
SimControlLanguageCommand(const std::string &name)
Definition: SimControlLanguageCommand.cc:67
SetProcedureTransferTracing
Definition: SettingCommand.cc:572
SetFUConflictDetection
Definition: SettingCommand.cc:204
SettingCommand::settings_
SettingMap settings_
storage for simulator settings
Definition: SettingCommand.hh:80
Texts::TXT_INTERP_SETTING_HISTORY_SIZE
@ TXT_INTERP_SETTING_HISTORY_SIZE
Description of the execution trace setting.
Definition: SimulatorTextGenerator.hh:152
Texts::TXT_INTERP_SETTING_HISTORY_FILENAME
@ TXT_INTERP_SETTING_HISTORY_FILENAME
Definition: SimulatorTextGenerator.hh:148
SimulatorInterpreter
Definition: SimulatorInterpreter.hh:49
SetSimulationTimeStatistics
Definition: SettingCommand.cc:284
Texts::TXT_INTERP_SETTING_UTILIZATION_SAVING
@ TXT_INTERP_SETTING_UTILIZATION_SAVING
Definition: SimulatorTextGenerator.hh:200
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
Texts::TXT_SIMULATION_TIME_STATISTICS
@ TXT_SIMULATION_TIME_STATISTICS
Description of the simulation time statistics setting.
Definition: SimulatorTextGenerator.hh:154
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
Texts::TXT_SIMULATION_TIMEOUT
@ TXT_SIMULATION_TIMEOUT
Simulation timeout in seconds.
Definition: SimulatorTextGenerator.hh:156
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
Texts::TXT_INTERP_SETTING_PROFILE_SAVING
@ TXT_INTERP_SETTING_PROFILE_SAVING
Definition: SimulatorTextGenerator.hh:201
SetMemoryAccessTracking
Definition: SettingCommand.cc:611
SetSimulationTimeout
Definition: SettingCommand.cc:322
SetNextInstructionPrinting
Definition: SettingCommand.cc:244
Texts::TXT_INTERP_HELP_SETTING
@ TXT_INTERP_HELP_SETTING
Help text for command "setting" of the CLI.
Definition: SimulatorTextGenerator.hh:77
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
SetUtilizationSaving
Definition: SettingCommand.cc:401
DataObject::setString
virtual void setString(std::string value)
Definition: DataObject.cc:130
Texts::TXT_INTERP_SETTING_EXECTRACE
@ TXT_INTERP_SETTING_EXECTRACE
Definition: SimulatorTextGenerator.hh:145
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
Texts::TXT_INTERP_SETTING_FU_CONFLICT_DETECTION
@ TXT_INTERP_SETTING_FU_CONFLICT_DETECTION
Definition: SimulatorTextGenerator.hh:151