99 lines
2.1 KiB
C++
99 lines
2.1 KiB
C++
/*
|
|
* DebugManager.cpp
|
|
*
|
|
* Created on: Mar 20, 2014
|
|
* Author: jonny
|
|
*/
|
|
|
|
#include "DebugManager.h"
|
|
#include <string>
|
|
#include <algorithm>
|
|
|
|
using namespace std;
|
|
|
|
DebugManager& DebugManager::getInstance()
|
|
{
|
|
static DebugManager manager;
|
|
return manager;
|
|
}
|
|
|
|
void DebugManager::printDebugMessage(string message, Sender sender, Importance importance)
|
|
{
|
|
bool show = count(whiteList.begin(), whiteList.end(),
|
|
pair<Sender, Importance>(sender, importance));
|
|
if (show)
|
|
{
|
|
cout << importanceToString(importance);
|
|
if (printTime)
|
|
std::cout << " at " << sc_time_stamp();
|
|
if (printLocation)
|
|
std::cout << " in " << senderToString(sender);
|
|
cout << ": " << message << endl;
|
|
}
|
|
}
|
|
|
|
void DebugManager::printDebugMessage(std::string message, Sender sender, unsigned int senderNumber,
|
|
Importance importance)
|
|
{
|
|
bool show = count(whiteList.begin(), whiteList.end(),
|
|
pair<Sender, Importance>(sender, importance));
|
|
|
|
if (show)
|
|
{
|
|
cout << importanceToString(importance);
|
|
if (printTime)
|
|
std::cout << " at " << sc_time_stamp();
|
|
if (printLocation)
|
|
std::cout << " in " << senderToString(sender) << "number " << senderNumber;
|
|
cout << ": " << message << endl;
|
|
}
|
|
}
|
|
|
|
|
|
void DebugManager::addToWhiteList(Sender sender, Importance importance)
|
|
{
|
|
whiteList.push_back(pair<Sender, Importance>(sender, importance));
|
|
}
|
|
|
|
void DebugManager::addToWhiteList(Sender sender)
|
|
{
|
|
addToWhiteList(sender, Importance::Info);
|
|
addToWhiteList(sender, Importance::Warning);
|
|
}
|
|
|
|
|
|
string DebugManager::importanceToString(Importance importancy)
|
|
{
|
|
switch (importancy)
|
|
{
|
|
case Importance::Info:
|
|
return "";
|
|
case Importance::Warning:
|
|
return "[Warning]";
|
|
}
|
|
return "unknown importance";
|
|
}
|
|
|
|
string DebugManager::senderToString(Sender sender)
|
|
{
|
|
switch (sender)
|
|
{
|
|
case Sender::DramController:
|
|
return "DRAM core";
|
|
case Sender::DramWrapper:
|
|
return "DRAM Wrapper";
|
|
case Sender::Scheduler:
|
|
return "Scheduler";
|
|
case Sender::TracePlayer:
|
|
return "TracePlayer";
|
|
case Sender::TraceRecorder:
|
|
return "TraceRecorder";
|
|
}
|
|
return "unknown sender";
|
|
}
|
|
|
|
void reportFatal(std::string sender, std::string message)
|
|
{
|
|
SC_REPORT_FATAL(sender.c_str(), message.c_str());
|
|
}
|