OpenASIP 2.2
Loading...
Searching...
No Matches
BackTraceCommand.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2010 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file BackTraceCommand.cc
26 *
27 * Implementation of BackTraceCommand class
28 *
29 * @author Pekka Jääskeläinen 2010
30 * @note rating: red
31 */
32
33#include "BackTraceCommand.hh"
35#include "CallPathTracker.hh"
36#include "Procedure.hh"
37#include "Program.hh"
38#include "Instruction.hh"
39
42
45
46bool
47BackTraceCommand::execute(const std::vector<DataObject>& arguments) {
48 if (!checkArgumentCount(arguments.size() - 1, 0, 0)) {
49 return false;
50 }
51
53 return false;
54 }
55
56 SimulatorInterpreterContext& interpreterContext =
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) {
85 << "called ";
86 } else {
88 << "returned to ";
89 }
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}
115
116std::string
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}
123
#define assert(condition)
virtual std::string helpText() const
virtual ~BackTraceCommand()
virtual bool execute(const std::vector< DataObject > &arguments)
std::deque< ProcedureTransfer > ProcedureTransferQueue
const ProcedureTransferQueue & transfers() const
const ProcedureTransferQueue backTrace() const
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
std::string name() const
ScriptInterpreter * interpreter() const
virtual InterpreterContext & context() const =0
void setErrorMessage(const TCEString &errorMsg)
virtual std::ostream & outputStream()
std::size_t callHistoryLength() const
const CallPathTracker & callPathTracker(int core=-1) const
const TTAProgram::Program & program() const
Instruction & instructionAt(InstructionAddress address) const
Definition Program.cc:374