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

#include <BackTraceCommand.hh>

Inheritance diagram for BackTraceCommand:
Inheritance graph
Collaboration diagram for BackTraceCommand:
Collaboration graph

Public Member Functions

 BackTraceCommand ()
 
virtual ~BackTraceCommand ()
 
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 back trace command of the Simulator Control Language.

Definition at line 47 of file BackTraceCommand.hh.

Constructor & Destructor Documentation

◆ BackTraceCommand()

BackTraceCommand::BackTraceCommand ( )

Definition at line 40 of file BackTraceCommand.cc.

41 }

◆ ~BackTraceCommand()

BackTraceCommand::~BackTraceCommand ( )
virtual

Definition at line 43 of file BackTraceCommand.cc.

43  {
44 }

Member Function Documentation

◆ execute()

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

Implements CustomCommand.

Definition at line 47 of file BackTraceCommand.cc.

47  {
48  if (!checkArgumentCount(arguments.size() - 1, 0, 0)) {
49  return false;
50  }
51 
52  if (!checkSimulationStopped()) {
53  return false;
54  }
55 
56  SimulatorInterpreterContext& interpreterContext =
57  dynamic_cast<SimulatorInterpreterContext&>(interpreter()->context());
58 
60  interpreterContext.simulatorFrontend();
61 
64  "Call history logging not enabled.\n"
65  "Use 'setting call_history_length' to enable.");
66  return false;
67  }
68 
70 
71 #if 0
72  // move this to a separate call_path command or similar
73  const CallPathTracker::ProcedureTransferQueue& callHistory =
74  cpt.transfers();
75 
76  for (CallPathTracker::ProcedureTransferQueue::const_iterator i =
77  callHistory.begin(); i != callHistory.end(); ++i) {
79  TCEString procName =
80  dynamic_cast<const TTAProgram::Procedure&>(
82  parent()).name();
83  if (tr.isEntry) {
84  outputStream()
85  << "called ";
86  } else {
87  outputStream()
88  << "returned to ";
89  }
90  outputStream()
91  << procName << "@" << tr.sourceAddress << std::endl;
92  }
93 #endif
94 
96  cpt.backTrace();
97  int callLevel = 0;
98  CallPathTracker::ProcedureTransferQueue::const_iterator i =
99  calls.begin();
100  for (; i != calls.end(); ++i) {
102  TCEString procName =
103  dynamic_cast<const TTAProgram::Procedure&>(
105  parent()).name();
106  assert(tr.isEntry);
107  outputStream()
108  << "#" << callLevel << " called "
109  << procName << "@" << tr.sourceAddress << std::endl;
110  ++callLevel;
111  }
112 
113  return true;
114 }

References CallPathTracker::ProcedureTransfer::address, assert, CallPathTracker::backTrace(), SimulatorFrontend::callHistoryLength(), SimulatorFrontend::callPathTracker(), CustomCommand::checkArgumentCount(), SimControlLanguageCommand::checkSimulationStopped(), ScriptInterpreter::context(), TTAProgram::Program::instructionAt(), CustomCommand::interpreter(), CallPathTracker::ProcedureTransfer::isEntry, CustomCommand::name(), SimControlLanguageCommand::outputStream(), SimulatorFrontend::program(), SimControlLanguageCommand::setErrorMessage(), SimulatorInterpreterContext::simulatorFrontend(), SimControlLanguageCommand::simulatorFrontend(), CallPathTracker::ProcedureTransfer::sourceAddress, and CallPathTracker::transfers().

Here is the call graph for this function:

◆ helpText()

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

Implements CustomCommand.

Definition at line 117 of file BackTraceCommand.cc.

117  {
118  return std::string(
119  "Prints the current call stack (back trace).\n"
120  "Requires call history saving to be on.\n"
121  "See 'setting call_history_length'.");
122 }

The documentation for this class was generated from the following files:
SimulatorFrontend::callPathTracker
const CallPathTracker & callPathTracker(int core=-1) const
Definition: SimulatorFrontend.cc:2393
SimulatorInterpreterContext
Definition: SimulatorInterpreterContext.hh:45
CustomCommand::checkArgumentCount
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
Definition: CustomCommand.cc:82
CustomCommand::name
std::string name() const
SimControlLanguageCommand::outputStream
virtual std::ostream & outputStream()
Definition: SimControlLanguageCommand.cc:351
SimControlLanguageCommand::checkSimulationStopped
bool checkSimulationStopped()
Definition: SimControlLanguageCommand.cc:135
SimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimulatorFrontend.cc:276
CallPathTracker::ProcedureTransfer::sourceAddress
InstructionAddress sourceAddress
Definition: CallPathTracker.hh:56
SimulatorFrontend::callHistoryLength
std::size_t callHistoryLength() const
Definition: SimulatorFrontend.hh:267
CallPathTracker::transfers
const ProcedureTransferQueue & transfers() const
Definition: CallPathTracker.hh:76
SimulatorInterpreterContext::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimulatorInterpreterContext.cc:61
CallPathTracker::ProcedureTransferQueue
std::deque< ProcedureTransfer > ProcedureTransferQueue
Definition: CallPathTracker.hh:60
CallPathTracker
Definition: CallPathTracker.hh:51
SimControlLanguageCommand::setErrorMessage
void setErrorMessage(const TCEString &errorMsg)
Definition: SimControlLanguageCommand.cc:738
assert
#define assert(condition)
Definition: Application.hh:86
CallPathTracker::ProcedureTransfer::address
InstructionAddress address
Definition: CallPathTracker.hh:55
TTAProgram::Program::instructionAt
Instruction & instructionAt(InstructionAddress address) const
Definition: Program.cc:374
SimControlLanguageCommand::SimControlLanguageCommand
SimControlLanguageCommand(const std::string &name)
Definition: SimControlLanguageCommand.cc:67
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
CallPathTracker::ProcedureTransfer
Definition: CallPathTracker.hh:53
TCEString
Definition: TCEString.hh:53
CallPathTracker::ProcedureTransfer::isEntry
bool isEntry
Definition: CallPathTracker.hh:57
CallPathTracker::backTrace
const ProcedureTransferQueue backTrace() const
Definition: CallPathTracker.cc:54
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
TTAProgram::Procedure
Definition: Procedure.hh:55
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
ScriptInterpreter::context
virtual InterpreterContext & context() const =0