Simplify trace recording.

This commit is contained in:
Lukas Steiner
2021-06-01 11:58:53 +02:00
parent 9949c36f83
commit eefbbb5235
2 changed files with 4 additions and 38 deletions

View File

@@ -117,19 +117,12 @@ void TlmRecorder::recordPhase(tlm_generic_payload &trans,
if (currentTransactionsInSystem.find(&trans) == currentTransactionsInSystem.end())
introduceTransactionSystem(trans);
std::string phaseName = getPhaseName(phase);
std::string phaseBeginPrefix = "BEGIN_";
std::string phaseEndPrefix = "END_";
if (phase == END_REQ || phase == END_RESP || phase >= END_PDNA)
{
phaseName.erase(0, phaseEndPrefix.length());
currentTransactionsInSystem[&trans].setPhaseEnd(phaseName, time);
}
currentTransactionsInSystem[&trans].recordedPhases.back().interval.end = time;
else
{
phaseName.erase(0, phaseBeginPrefix.length());
currentTransactionsInSystem[&trans].insertPhase(phaseName, time);
std::string phaseName = getPhaseName(phase).substr(6); // remove "BEGIN_"
currentTransactionsInSystem[&trans].recordedPhases.emplace_back(phaseName, time);
}
if (currentTransactionsInSystem[&trans].cmd == 'X')
@@ -256,30 +249,6 @@ void TlmRecorder::commitRecordedDataToDB()
sqlite3_exec(db, "COMMIT;", nullptr, nullptr, nullptr);
}
void TlmRecorder::Transaction::insertPhase(const std::string &phaseName, const sc_time &begin)
{
recordedPhases.emplace_back(phaseName, begin);
}
void TlmRecorder::Transaction::setPhaseEnd(const std::string &phaseName, const sc_time &end)
{
// Find the latest recorder phase for that transaction with a matching phaseName and update it
// Note: Transactions might have the same phase multiple times (e.g. PRE->ACT->REF->ACT->RD)
// only update the latest one that has been recorded
for (size_t i = recordedPhases.size(); i > 0; i--)
{
Phase &data = recordedPhases[i - 1];
if (data.name == phaseName)
{
data.interval.end = end;
return;
}
}
SC_REPORT_FATAL("Recording Error",
"While trying to set phase end: phaseBegin has not been recorded");
}
void TlmRecorder::openDB(const std::string &dbName)
{
std::ifstream f(dbName.c_str());
@@ -287,7 +256,7 @@ void TlmRecorder::openDB(const std::string &dbName)
{
if (remove(dbName.c_str()) != 0)
{
SC_REPORT_FATAL("TlmRecorder", "Error deleting file" );
SC_REPORT_FATAL("TlmRecorder", "Error deleting file");
}
}

View File

@@ -103,9 +103,6 @@ private:
TimeInterval interval;
};
std::vector<Phase> recordedPhases;
void insertPhase(const std::string &phaseName, const sc_time &begin);
void setPhaseEnd(const std::string &phaseName, const sc_time &end);
};
std::string name;