OpenASIP
2.0
|
#include <SimControlLanguageCommand.hh>
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) |
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.
SimControlLanguageCommand::SimControlLanguageCommand | ( | const std::string & | name | ) |
Constructor.
Sets the name of the command to the base class.
name | Name of the command to add. |
Definition at line 67 of file SimControlLanguageCommand.cc.
|
virtual |
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.
target | The target to put the condition script in. |
Definition at line 513 of file SimControlLanguageCommand.cc.
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().
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.
target | The target to put the expression script in. |
Definition at line 551 of file SimControlLanguageCommand.cc.
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().
bool SimControlLanguageCommand::checkMachineLoaded | ( | ) |
Checks that the simulated machine has been loaded successfully.
Definition at line 199 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::setError(), and simulatorFrontend().
bool SimControlLanguageCommand::checkProgramLoaded | ( | ) |
Checks that the simulated program has been loaded successfully.
Definition at line 180 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::setError(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_NO_PROGRAM_LOADED.
Referenced by MemDumpCommand::execute(), SymbolAddressCommand::execute(), MemWriteCommand::execute(), and DisassembleCommand::execute().
bool SimControlLanguageCommand::checkSimulationEnded | ( | ) |
Checks that the simulation has ended.
Sets errors message and returns false if simulation has not ended.
Definition at line 158 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_NOT_ENDED.
Referenced by KillCommand::execute().
bool SimControlLanguageCommand::checkSimulationInitialized | ( | ) |
Checks that the simulation is initialized and ready to run.
Sets errors message and returns false if simulation is not initialized.
Definition at line 88 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_NOT_INITIALIZED.
Referenced by ConditionCommand::execute(), UntilCommand::execute(), StepiCommand::execute(), DeleteBPCommand::execute(), RunCommand::execute(), NextiCommand::execute(), IgnoreCommand::execute(), EnableBPCommand::execute(), DisableBPCommand::execute(), and parseBreakpoint().
bool SimControlLanguageCommand::checkSimulationNotAlreadyRunning | ( | ) |
Checks that the simulation is not already running.
Sets errors message and returns false if simulation is running.
Definition at line 111 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_ALREDY_RUNNING.
Referenced by RunCommand::execute().
bool SimControlLanguageCommand::checkSimulationStopped | ( | ) |
Checks that the simulation is stopped.
Sets errors message and returns false if simulation is not stopped by the user.
Definition at line 135 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), simulatorFrontend(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_SIMULATION_NOT_RUNNING.
Referenced by KillCommand::execute(), UntilCommand::execute(), StepiCommand::execute(), ConditionCommand::execute(), ResumeCommand::execute(), DisableBPCommand::execute(), DeleteBPCommand::execute(), IgnoreCommand::execute(), EnableBPCommand::execute(), NextiCommand::execute(), BackTraceCommand::execute(), and parseBreakpoint().
|
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.
Definition at line 351 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::lineReader(), and LineReader::outputStream().
Referenced by HelpCommand::execute(), ProgCommand::execute(), BackTraceCommand::execute(), CommandsCommand::execute(), DisassembleCommand::execute(), SettingCommand::execute(), InfoProcCommand::execute(), InfoProgramCommand::execute(), printBreakpointInfo(), printNextInstruction(), printSimulationTime(), and printStopReasons().
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.
arguments | as passed to the execute() of the command. |
target | the breakpoint instance to put the parsed data to. |
Definition at line 593 of file SimControlLanguageCommand.cc.
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().
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.
expression | The expression to parse. |
IllegalParameters | when expression could not be parsed to an address. |
Definition at line 471 of file SimControlLanguageCommand.cc.
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().
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.
expression | The expression to parse. |
IllegalParameters | when expression could not be parsed to an address. |
Definition at line 378 of file SimControlLanguageCommand.cc.
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 UntilCommand::execute(), DisassembleCommand::execute(), and parseBreakpoint().
|
virtual |
Prints information of a breakpoint.
If breakpoint with the given handle could not be found, sets error to the interpreter and returns false.
breakpointHandle | The handle of the breakpoint to be printed. |
Definition at line 678 of file SimControlLanguageCommand.cc.
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(), WatchCommand::execute(), TBPCommand::execute(), ConditionCommand::execute(), IgnoreCommand::execute(), EnableBPCommand::execute(), DisableBPCommand::execute(), and InfoBreakpointsCommand::execute().
|
virtual |
Prints the next simulated instruction to the simulator console.
Definition at line 228 of file SimControlLanguageCommand.cc.
References outputStream(), SimulatorFrontend::programLocationDescription(), and simulatorFrontend().
Referenced by NextiCommand::execute(), UntilCommand::execute(), StepiCommand::execute(), and printStopInformation().
|
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.
References SimulatorFrontend::lastRunCycleCount(), SimulatorFrontend::lastRunTime(), outputStream(), and simulatorFrontend().
Referenced by StepiCommand::execute(), UntilCommand::execute(), and 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().
|
virtual |
Prints the reasons why simulation has been stopped.
Definition at line 257 of file SimControlLanguageCommand.cc.
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().
void SimControlLanguageCommand::setErrorMessage | ( | const TCEString & | errorMsg | ) |
Definition at line 738 of file SimControlLanguageCommand.cc.
References CustomCommand::interpreter(), ScriptInterpreter::setResult(), and DataObject::setString().
Referenced by BackTraceCommand::execute().
|
protected |
Parses the address string to corresponding memory address and address space.
addressString | Memory address command string to parse. |
addressSpaceName | Address space name to be set. |
memoryAddress | Memory address to be set. |
Definition at line 753 of file SimControlLanguageCommand.cc.
References TTAMachine::NullAddressSpace::instance(), TTAProgram::Address::location(), TTAMachine::Component::name(), parseDataAddressExpression(), and TTAProgram::Address::space().
Referenced by MemDumpCommand::execute(), and MemWriteCommand::execute().
|
protected |
Sets memory instance from a given AddressSpaceName to given memory.
memory | Memory pointer to be set |
addressSpaceName | The name of the address space. |
must have the address space defined
Definition at line 780 of file SimControlLanguageCommand.cc.
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().
SimulatorFrontend & SimControlLanguageCommand::simulatorFrontend | ( | ) |
Returns the SimulatorFrontend instance stored in the context.
Definition at line 214 of file SimControlLanguageCommand.cc.
References assert, ScriptInterpreter::context(), CustomCommand::interpreter(), and SimulatorInterpreterContext::simulatorFrontend().
Referenced by checkMachineLoaded(), checkProgramLoaded(), checkSimulationEnded(), checkSimulationInitialized(), checkSimulationNotAlreadyRunning(), checkSimulationStopped(), ProgCommand::execute(), KillCommand::execute(), WatchCommand::execute(), DeleteBPCommand::execute(), BackTraceCommand::execute(), DisableBPCommand::execute(), StepiCommand::execute(), MemDumpCommand::execute(), BPCommand::execute(), UntilCommand::execute(), NextiCommand::execute(), ConditionCommand::execute(), ResumeCommand::execute(), RunCommand::execute(), EnableBPCommand::execute(), IgnoreCommand::execute(), TBPCommand::execute(), SymbolAddressCommand::execute(), SettingCommand::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(), parseDataAddressExpression(), parseInstructionAddressExpression(), printBreakpointInfo(), printNextInstruction(), printSimulationTime(), printStopReasons(), setMemoryPointer(), and verifyBreakpointHandles().
const SimulatorFrontend& SimControlLanguageCommand::simulatorFrontendConst | ( | ) |
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.
arguments | The arguments as given to the execute() of the command. |
startIndex | The first argument to check. |
Definition at line 712 of file SimControlLanguageCommand.cc.
References CustomCommand::checkPositiveIntegerArgument(), CustomCommand::interpreter(), ScriptInterpreter::setError(), simulatorFrontend(), SimulatorFrontend::stopPointManager(), StopPointManager::stopPointWithHandleConst(), SimulatorToolbox::textGenerator(), and Texts::TXT_BREAKPOINT_NOT_FOUND.
Referenced by DeleteBPCommand::execute(), EnableBPCommand::execute(), and DisableBPCommand::execute().