OpenASIP  2.0
ExecutionTrace.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 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 ExecutionTrace.hh
26  *
27  * Declaration of ExecutionTrace class.
28  *
29  * @author Pekka Jääskeläinen 2004,2009 (pjaaskel-no.spam-cs.tut.fi)
30  */
31 
32 #ifndef TTA_EXECUTION_TRACE_HH
33 #define TTA_EXECUTION_TRACE_HH
34 
35 #include <string>
36 #include <vector>
37 #include <list>
38 #include <fstream>
39 
40 #include "boost/tuple/tuple.hpp"
41 
42 #include "SimValue.hh"
43 #include "FileSystem.hh"
44 #include "RelationalDB.hh"
45 #include "SimulatorConstants.hh"
46 
47 
49 
50 /**
51  * The main class of the Execution Trace Database (TraceDB).
52  *
53  * Access to the execution trace database happens through the interface of
54  * this class.
55  */
57 public:
58 
59  /// a type for storing address space identifiers
60  typedef std::string AddressSpaceID;
61 
62  /// a type for storing bus identifiers
63  typedef std::string BusID;
64 
65  /// a type for storing socket identifiers
66  typedef std::string SocketID;
67 
68  /// a type for storing bus segment identifiers
69  typedef std::string SegmentID;
70 
71  /// a type for storing function unit identifiers
72  typedef std::string FunctionUnitID;
73 
74  /// a type for storing operation identifiers
75  typedef std::string OperationID;
76 
77  /// a type for storing register file identifiers
78  typedef std::string RegisterFileID;
79 
80  /// a type for storing register ids
81  typedef int RegisterID;
82 
83  /// a type for storing memory addresses
84  typedef unsigned int MemoryAddress;
85 
86  /// a type for storing data of size of the minimum addressable unit
87  typedef SimValue MAU;
88 
89  /// a type for register access counts
90  typedef std::size_t RegisterAccessCount;
91 
92  /// a type for operation trigger counts
94 
95  /// a type for storing procedure entry type (entry/exit)
97  PT_ENTRY = 0, ///< procedure entry
98  PT_EXIT = 1 ///< procedure exit
99  };
100 
101  /// type to be used as a key for storing concurrent RF access info
102  typedef boost::tuple<
103  RegisterAccessCount, /* concurrent reads */
104  RegisterAccessCount, /* concurrent writes */
106 
107  /// type to be used for a list of concurrent RF accesses
108  typedef std::list<ConcurrentRFAccessCount> ConcurrentRFAccessCountList;
109 
110  /// type to be used as a key for storing function unit operation execution
111  /// counts
112  typedef boost::tuple<OperationID, OperationTriggerCount>
114 
115  /// type to be used for lists of function operation execution counts
116  typedef std::list<FUOperationTriggerCount> FUOperationTriggerCountList;
117 
119  ClockCycleCount cycle, InstructionAddress address);
120 
122  InstructionAddress address, ClockCycleCount count);
123 
125  InstructionAddress firstAddress, InstructionAddress lastAddress,
126  const std::string& procedureName);
127 
128  void addLockedCycle(ClockCycleCount cycle);
129 
131 
132  void addMemoryAccess(
133  ClockCycleCount cycle,
134  const AddressSpaceID& addressSpace,
135  MemoryAddress address,
136  bool write,
137  std::size_t size,
138  const std::vector<MAU>* data = NULL);
139 
141 
143 
144  void addBusActivity(
145  ClockCycleCount cycle, const BusID& busId, const SegmentID& segmentId,
146  bool squash, const SimValue& data = NullSimValue::instance());
147 
149  RegisterFileID registerFile, RegisterAccessCount reads,
150  RegisterAccessCount writes, ClockCycleCount count);
151 
153  RegisterFileID registerFile, RegisterID registerIndex,
154  ClockCycleCount reads, ClockCycleCount writes);
155 
157  RegisterFileID registerFile) const;
158 
160  FunctionUnitID functionUnit, OperationID operation,
161  OperationTriggerCount count);
162 
164  ClockCycleCount cycle, InstructionAddress address,
165  InstructionAddress sourceAddress, ProcedureEntryType type);
166 
168  FunctionUnitID functionUnit) const;
169 
171 
173 
174  void addBusWriteCount(BusID socket, ClockCycleCount count);
175 
177 
179 
181 
183 
184  static ExecutionTrace* open(const std::string& fileName);
185 
186  virtual ~ExecutionTrace();
187 
188 protected:
189 
190  ExecutionTrace(const std::string& fileName, bool readOnly);
191  void open();
192 
193 private:
194  void initialize();
195 
196  /// Filename of the trace database (sqlite file).
197  const std::string& fileName_;
198  /// The call trace file.
199  std::fstream callTrace_;
200  /// The instruction profile file.
201  std::fstream instructionProfile_;
202  /// Is the database access mode read-only?
203  bool readOnly_;
204  /// Handle to the sqlite trace database.
206  /// Handle to the database connection;
208  /// Handle object for the queries of instruction executions.
210 
211 };
212 
213 #endif
ExecutionTrace::ProcedureEntryType
ProcedureEntryType
a type for storing procedure entry type (entry/exit)
Definition: ExecutionTrace.hh:96
ExecutionTrace::socketWriteCount
ClockCycleCount socketWriteCount(SocketID socket) const
Definition: ExecutionTrace.cc:656
ExecutionTrace::AddressSpaceID
std::string AddressSpaceID
a type for storing address space identifiers
Definition: ExecutionTrace.hh:60
RelationalDBConnection
Definition: RelationalDBConnection.hh:48
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
ExecutionTrace::OperationTriggerCount
ClockCycleCount OperationTriggerCount
a type for operation trigger counts
Definition: ExecutionTrace.hh:93
FileSystem.hh
ExecutionTrace::addBusWriteCount
void addBusWriteCount(BusID socket, ClockCycleCount count)
Definition: ExecutionTrace.cc:688
ExecutionTrace::PT_EXIT
@ PT_EXIT
procedure exit
Definition: ExecutionTrace.hh:98
ExecutionTrace::MemoryAddress
unsigned int MemoryAddress
a type for storing memory addresses
Definition: ExecutionTrace.hh:84
ExecutionTrace::fileName_
const std::string & fileName_
Filename of the trace database (sqlite file).
Definition: ExecutionTrace.hh:197
ExecutionTrace::open
void open()
Definition: ExecutionTrace.cc:169
ExecutionTrace::ExecutionTrace
ExecutionTrace(const std::string &fileName, bool readOnly)
Definition: ExecutionTrace.cc:180
NullSimValue::instance
static SimValue & instance()
Definition: SimValue.cc:1642
ExecutionTrace::FUOperationTriggerCountList
std::list< FUOperationTriggerCount > FUOperationTriggerCountList
type to be used for lists of function operation execution counts
Definition: ExecutionTrace.hh:116
RelationalDB.hh
ExecutionTrace::PT_ENTRY
@ PT_ENTRY
procedure entry
Definition: ExecutionTrace.hh:97
ExecutionTrace::addRegisterAccessCount
void addRegisterAccessCount(RegisterFileID registerFile, RegisterID registerIndex, ClockCycleCount reads, ClockCycleCount writes)
Definition: ExecutionTrace.cc:475
ExecutionTrace::MAU
SimValue MAU
a type for storing data of size of the minimum addressable unit
Definition: ExecutionTrace.hh:87
ExecutionTrace::RegisterFileID
std::string RegisterFileID
a type for storing register file identifiers
Definition: ExecutionTrace.hh:78
ExecutionTrace::addFunctionUnitOperationTriggerCount
void addFunctionUnitOperationTriggerCount(FunctionUnitID functionUnit, OperationID operation, OperationTriggerCount count)
Definition: ExecutionTrace.cc:546
SimValue
Definition: SimValue.hh:96
SimulatorConstants.hh
ExecutionTrace::SocketID
std::string SocketID
a type for storing socket identifiers
Definition: ExecutionTrace.hh:66
ExecutionTrace::instructionProfile_
std::fstream instructionProfile_
The instruction profile file.
Definition: ExecutionTrace.hh:201
ExecutionTrace::busWriteCount
ClockCycleCount busWriteCount(BusID bus) const
Definition: ExecutionTrace.cc:713
ExecutionTrace::addBasicBlockStart
void addBasicBlockStart(ClockCycleCount cycle, InstructionAddress address)
InstructionExecution
Definition: InstructionExecution.hh:45
ExecutionTrace
Definition: ExecutionTrace.hh:56
ExecutionTrace::~ExecutionTrace
virtual ~ExecutionTrace()
Definition: ExecutionTrace.cc:202
ExecutionTrace::addProcedureEntry
void addProcedureEntry(ClockCycleCount cycle, InstructionAddress address)
RelationalDB
Definition: RelationalDB.hh:47
ExecutionTrace::BusID
std::string BusID
a type for storing bus identifiers
Definition: ExecutionTrace.hh:63
ExecutionTrace::db_
RelationalDB * db_
Handle to the sqlite trace database.
Definition: ExecutionTrace.hh:205
ExecutionTrace::OperationID
std::string OperationID
a type for storing operation identifiers
Definition: ExecutionTrace.hh:75
ExecutionTrace::instructionExecutions
InstructionExecution & instructionExecutions()
Definition: ExecutionTrace.cc:363
ExecutionTrace::SegmentID
std::string SegmentID
a type for storing bus segment identifiers
Definition: ExecutionTrace.hh:69
ExecutionTrace::addInstructionExecution
void addInstructionExecution(ClockCycleCount cycle, InstructionAddress address)
Definition: ExecutionTrace.cc:279
ExecutionTrace::instructionExecution_
InstructionExecution * instructionExecution_
Handle object for the queries of instruction executions.
Definition: ExecutionTrace.hh:209
ExecutionTrace::readOnly_
bool readOnly_
Is the database access mode read-only?
Definition: ExecutionTrace.hh:203
ExecutionTrace::functionUnitOperationTriggerCounts
FUOperationTriggerCountList * functionUnitOperationTriggerCounts(FunctionUnitID functionUnit) const
Definition: ExecutionTrace.cc:591
ExecutionTrace::addProcedureExit
void addProcedureExit(ClockCycleCount cycle, InstructionAddress address)
ExecutionTrace::FunctionUnitID
std::string FunctionUnitID
a type for storing function unit identifiers
Definition: ExecutionTrace.hh:72
ExecutionTrace::registerFileAccessCounts
ConcurrentRFAccessCountList * registerFileAccessCounts(RegisterFileID registerFile) const
Definition: ExecutionTrace.cc:505
ExecutionTrace::addConcurrentRegisterFileAccessCount
void addConcurrentRegisterFileAccessCount(RegisterFileID registerFile, RegisterAccessCount reads, RegisterAccessCount writes, ClockCycleCount count)
Definition: ExecutionTrace.cc:440
ExecutionTrace::addProcedureAddressRange
void addProcedureAddressRange(InstructionAddress firstAddress, InstructionAddress lastAddress, const std::string &procedureName)
Definition: ExecutionTrace.cc:335
ExecutionTrace::addLockedCycle
void addLockedCycle(ClockCycleCount cycle)
SimValue.hh
ExecutionTrace::initialize
void initialize()
Definition: ExecutionTrace.cc:243
ExecutionTrace::addMemoryAccess
void addMemoryAccess(ClockCycleCount cycle, const AddressSpaceID &addressSpace, MemoryAddress address, bool write, std::size_t size, const std::vector< MAU > *data=NULL)
ExecutionTrace::simulatedCycleCount
ClockCycleCount simulatedCycleCount() const
Definition: ExecutionTrace.cc:764
ExecutionTrace::addBusActivity
void addBusActivity(ClockCycleCount cycle, const BusID &busId, const SegmentID &segmentId, bool squash, const SimValue &data=NullSimValue::instance())
Definition: ExecutionTrace.cc:391
ExecutionTrace::addInstructionExecutionCount
void addInstructionExecutionCount(InstructionAddress address, ClockCycleCount count)
Definition: ExecutionTrace.cc:304
ExecutionTrace::ConcurrentRFAccessCount
boost::tuple< RegisterAccessCount, RegisterAccessCount, ClockCycleCount > ConcurrentRFAccessCount
type to be used as a key for storing concurrent RF access info
Definition: ExecutionTrace.hh:105
ExecutionTrace::callTrace_
std::fstream callTrace_
The call trace file.
Definition: ExecutionTrace.hh:199
ExecutionTrace::addProcedureTransfer
void addProcedureTransfer(ClockCycleCount cycle, InstructionAddress address, InstructionAddress sourceAddress, ProcedureEntryType type)
Definition: ExecutionTrace.cc:575
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
ExecutionTrace::ConcurrentRFAccessCountList
std::list< ConcurrentRFAccessCount > ConcurrentRFAccessCountList
type to be used for a list of concurrent RF accesses
Definition: ExecutionTrace.hh:108
ExecutionTrace::RegisterID
int RegisterID
a type for storing register ids
Definition: ExecutionTrace.hh:81
ExecutionTrace::FUOperationTriggerCount
boost::tuple< OperationID, OperationTriggerCount > FUOperationTriggerCount
type to be used as a key for storing function unit operation execution counts
Definition: ExecutionTrace.hh:113
ExecutionTrace::dbConnection_
RelationalDBConnection * dbConnection_
Handle to the database connection;.
Definition: ExecutionTrace.hh:207
ExecutionTrace::RegisterAccessCount
std::size_t RegisterAccessCount
a type for register access counts
Definition: ExecutionTrace.hh:90
ExecutionTrace::setSimulatedCycleCount
void setSimulatedCycleCount(ClockCycleCount count)
Definition: ExecutionTrace.cc:741
ExecutionTrace::addSocketWriteCount
void addSocketWriteCount(SocketID socket, ClockCycleCount)
Definition: ExecutionTrace.cc:631