Skip to content

Commit

Permalink
[BUGFIX] Added tracing to listing file
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Oct 18, 2024
1 parent 8cd2e8e commit 7052232
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 10 additions & 0 deletions TraceLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ void TraceLog::logLine(const std::string &str)
m_traceFile.flush();
}


void TraceLog::logListingLine(const std::string& str)
{
if (!_createFile(m_ListingFile, m_logFileName + ".listing.txt")) return;

m_ListingFile
<< str
<< std::endl;
m_ListingFile.flush();
}
void TraceLog::logNewSectionCalled(const ADDRINT prevAddr, const std::string &prevSection, const std::string &currSection)
{
createFile();
Expand Down
17 changes: 12 additions & 5 deletions TraceLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class TraceLog
if (fileName.empty()) fileName = "output.txt";
m_logFileName = fileName;
m_shortLog = is_short;
createFile();
_createFile(m_traceFile, m_logFileName);
_createFile(m_ListingFile, m_logFileName + ".listing.txt");
}

void logCall(const ADDRINT prevModuleBase, const ADDRINT prevAddr, bool isRVA, const std::string &module, const std::string &func = "");
Expand All @@ -40,22 +41,28 @@ class TraceLog
void logSyscall(const ADDRINT base, const ADDRINT rva, const ADDRINT param, const std::string &funcName);

void logLine(const std::string &str);

void logListingLine(const std::string& str);
protected:

bool createFile()
{
if (m_traceFile.is_open()) {
return _createFile(m_traceFile, m_logFileName);
}

bool _createFile(std::ofstream &file, const std::string &fileName)
{
if (file.is_open()) {
return true;
}
m_traceFile.open(m_logFileName.c_str());
if (m_traceFile.is_open()) {
file.open(fileName.c_str());
if (file.is_open()) {
return true;
}
return false;
}

std::string m_logFileName;
std::ofstream m_traceFile;
std::ofstream m_ListingFile;
bool m_shortLog;
};

0 comments on commit 7052232

Please sign in to comment.