Go to the documentation of this file.
34 #include "boost/format.hpp"
49 "CREATE TABLE database_info ("
50 " version INTEGER PRIMARY KEY,"
51 " tpef_filename TEXT);";
54 "CREATE TABLE instruction_execution ("
55 " cycle INTEGER PRIMARY KEY,"
56 " address INTEGER NOT NULL);";
59 "CREATE TABLE procedure_address_range ("
60 " first_address INTEGER UNIQUE, "
61 " last_address INTEGER UNIQUE, "
62 " procedure_name TEXT NOT NULL);";
65 "CREATE TABLE bus_activity ("
66 " cycle INTEGER NOT NULL,"
68 " segment TEXT NOT NULL,"
69 " squash BOOLEAN DEFAULT false,"
70 " data_as_int INTEGER,"
71 " data_as_double REAL);";
74 "CREATE TABLE concurrent_register_file_access ("
75 " register_file TEXT NOT NULL,"
76 " reads INTEGER NOT NULL,"
77 " writes INTEGER NOT NULL,"
78 " count INTEGER NOT NULL);";
81 "CREATE TABLE register_access ("
82 " register_file TEXT NOT NULL,"
83 " register_index INTEGER NOT NULL,"
84 " reads INTEGER NOT NULL,"
85 " writes INTEGER NOT NULL);";
88 "CREATE TABLE fu_operation_triggers ("
89 " function_unit TEXT NOT NULL,"
90 " operation TEXT NOT NULL,"
91 " count INTEGER NOT NULL);";
94 "CREATE TABLE bus_write_counts ("
96 " writes INTEGER NOT NULL);";
99 "CREATE TABLE socket_write_counts ("
100 " socket TEXT NOT NULL,"
101 " writes INTEGER NOT NULL);";
104 "CREATE TABLE totals ("
105 " value_name TEXT NOT NULL,"
106 " integer_value INTEGER);";
181 fileName_(fileName), callTrace_(
182 (fileName +
".calls").c_str(),
183 (
FileSystem::fileExists(fileName) || readOnly) ?
185 std::fstream::out | std::fstream::trunc),
187 (fileName +
".profile").c_str(),
188 (
FileSystem::fileExists(fileName) || readOnly) ?
190 std::fstream::out | std::fstream::trunc),
191 readOnly_(readOnly), db_(new
SQLite()),
192 dbConnection_(NULL), instructionExecution_(NULL) {
232 "Exception almost leaked from ~ExecutionTrace! Message: " +
260 "INSERT INTO database_info(version) VALUES (%d);") %
265 std::string(
"") +
"Error while initializing TraceDB. " +
281 const std::string query =
283 "INSERT INTO instruction_execution(cycle, address) VALUES("
284 "%.0f, %d);") % cycle % address).str();
308 const std::string query =
309 "INSERT INTO instruction_execution_count(address, count) VALUES(" +
337 const std::string& procedureName) {
338 const std::string query =
339 "INSERT INTO procedure_address_range(first_address, last_address, "
340 "procedure_name) VALUES(" +
343 procedureName +
"');";
372 "SELECT * FROM instruction_execution ORDER BY cycle"));
393 bool squash,
const SimValue& data) {
395 "INSERT INTO bus_activity(cycle, bus, segment, squash, "
396 "data_as_int, data_as_double) VALUES(" +
406 if (doubleString ==
"nan")
407 doubleString =
"NULL";
413 query +=
", 0, 0.0)";
421 debugLog(std::string(
"query: ") + query);
443 const std::string query =
445 "INSERT INTO concurrent_register_file_access("
446 " register_file, reads, writes, count) "
447 "VALUES('" + registerFile +
"', " +
478 const std::string query =
480 "INSERT INTO register_access("
481 " register_file, register_index, reads, writes) "
482 "VALUES('%s', %d, %.0f, %.0f)")
483 % registerFile % registerIndex % reads % writes).str();
513 "SELECT * FROM concurrent_register_file_access " +
514 "WHERE register_file LIKE('" + registerFile +
"')");
520 (result->
data(
"reads")).integerValue(),
521 (result->
data(
"writes")).integerValue(),
522 (result->
data(
"count")).integerValue()));
549 const std::string query =
551 "INSERT INTO fu_operation_triggers("
552 " function_unit, operation, count) "
553 "VALUES('" + functionUnit +
"', '" + operation +
"', " +
579 << cycle <<
"\t" << address <<
"\t" << sourceAddress <<
"\t"
580 << type << std::endl;
600 "SELECT * FROM fu_operation_triggers WHERE function_unit "
601 "LIKE('" + functionUnit +
"')");
607 (result->
data(
"operation")).stringValue(),
608 (result->
data(
"count")).integerValue()));
632 const std::string query =
634 "INSERT INTO socket_write_counts(socket, writes) "
663 "SELECT writes FROM socket_write_counts "
664 "WHERE socket LIKE('%s')") % socket).str());
668 count = (result->
data(
"writes")).integerValue();
689 const std::string query =
691 "INSERT INTO bus_write_counts(bus, writes) "
720 "SELECT writes FROM bus_write_counts "
721 "WHERE bus LIKE('%s')") % bus).str());
725 count = (result->
data(
"writes")).integerValue();
742 const std::string query =
744 "INSERT INTO totals(value_name, integer_value) "
768 "SELECT integer_value FROM totals "
769 "WHERE value_name LIKE('cycle_count')");
775 "No 'cycle_count' entry in 'totals' table.");
ProcedureEntryType
a type for storing procedure entry type (entry/exit)
ClockCycleCount socketWriteCount(SocketID socket) const
const std::string CQ_DATABASE_INFO
database table creation queries (CQ)
UInt32 InstructionAddress
ClockCycleCount OperationTriggerCount
a type for operation trigger counts
void addBusWriteCount(BusID socket, ClockCycleCount count)
virtual int updateQuery(const std::string &queryString)=0
DoubleWord doubleWordValue() const
const std::string CQ_REGISTER_ACCESS
virtual RelationalDBConnection & connect(const std::string &database, const std::string &login="", const std::string &password="", bool readOnly=false)=0
const std::string & fileName_
Filename of the trace database (sqlite file).
virtual const DataObject & data(std::size_t column) const =0
static void writeToErrorLog(const std::string fileName, const int lineNumber, const std::string functionName, const std::string message, const int neededVerbosity=0)
ExecutionTrace(const std::string &fileName, bool readOnly)
static SimValue & instance()
std::list< FUOperationTriggerCount > FUOperationTriggerCountList
type to be used for lists of function operation execution counts
const std::string CQ_CONCURRENT_REGISTER_FILE_ACCESS
void addRegisterAccessCount(RegisterFileID registerFile, RegisterID registerIndex, ClockCycleCount reads, ClockCycleCount writes)
UIntWord uIntWordValue() const
static std::string toString(const T &source)
std::string RegisterFileID
a type for storing register file identifiers
void addFunctionUnitOperationTriggerCount(FunctionUnitID functionUnit, OperationID operation, OperationTriggerCount count)
std::string SocketID
a type for storing socket identifiers
#define assert(condition)
const int DB_VERSION
the version number of the database schema
std::fstream instructionProfile_
The instruction profile file.
ClockCycleCount busWriteCount(BusID bus) const
virtual void close(const RelationalDBConnection &connection)=0
static bool fileIsWritable(const std::string fileName)
const std::string CQ_INSTRUCTION_EXECUTION
const std::string CQ_TOTALS
const std::string CQ_BUS_WRITE_COUNTS
const std::string CQ_BUS_ACTIVITY
virtual ~ExecutionTrace()
std::string BusID
a type for storing bus identifiers
RelationalDB * db_
Handle to the sqlite trace database.
std::string OperationID
a type for storing operation identifiers
virtual RelationalDBQueryResult * query(const std::string &queryString, bool init=true)=0
InstructionExecution & instructionExecutions()
const std::string CQ_SOCKET_WRITE_COUNTS
std::string SegmentID
a type for storing bus segment identifiers
void addInstructionExecution(ClockCycleCount cycle, InstructionAddress address)
InstructionExecution * instructionExecution_
Handle object for the queries of instruction executions.
virtual void beginTransaction()=0
FUOperationTriggerCountList * functionUnitOperationTriggerCounts(FunctionUnitID functionUnit) const
std::string errorMessage() const
std::string FunctionUnitID
a type for storing function unit identifiers
ConcurrentRFAccessCountList * registerFileAccessCounts(RegisterFileID registerFile) const
void addConcurrentRegisterFileAccessCount(RegisterFileID registerFile, RegisterAccessCount reads, RegisterAccessCount writes, ClockCycleCount count)
static ExecutionTrace * open(const std::string &fileName)
virtual void DDLQuery(const std::string &queryString)=0
void addProcedureAddressRange(InstructionAddress firstAddress, InstructionAddress lastAddress, const std::string &procedureName)
const std::string CQ_PROCEDURE_ADDRESS_RANGE
static bool fileExists(const std::string fileName)
ClockCycleCount simulatedCycleCount() const
const std::string CQ_FU_OPERATION_TRIGGERS
void addBusActivity(ClockCycleCount cycle, const BusID &busId, const SegmentID &segmentId, bool squash, const SimValue &data=NullSimValue::instance())
void addInstructionExecutionCount(InstructionAddress address, ClockCycleCount count)
std::fstream callTrace_
The call trace file.
void addProcedureTransfer(ClockCycleCount cycle, InstructionAddress address, InstructionAddress sourceAddress, ProcedureEntryType type)
CycleCount ClockCycleCount
Alias for ClockCycleCount.
std::list< ConcurrentRFAccessCount > ConcurrentRFAccessCountList
type to be used for a list of concurrent RF accesses
int RegisterID
a type for storing register ids
RelationalDBConnection * dbConnection_
Handle to the database connection;.
std::size_t RegisterAccessCount
a type for register access counts
void setSimulatedCycleCount(ClockCycleCount count)
void addSocketWriteCount(SocketID socket, ClockCycleCount)