diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 6d8d590de..38c78e972 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -231,3 +231,32 @@ void ErrorLogger::ErrorMessage::FileLocation::setfile(const std::string &file) _file = file; _file = Path::fromNativeSeparators(_file); } + + +void ErrorLogger::ReportProgress(const char func[], const Token * const tok) +{ + if (!func) + { + time1 = std::time(NULL); + return; + } + + const std::time_t time2 = std::time(NULL); + if (time2 >= (time1 + 60)) + { + time1 = time2; + + // current time in the format "Www Mmm dd hh:mm:ss yyyy" + const std::string str(ctime(&time2)); + + // format a progress message + std::ostringstream ostr; + ostr << "progress:" + << " time=" << str.substr(11, 8) + << " function=" << func + << " parsed-line=" << tok->linenr(); + + // Report progress message + reportOut(ostr.str()); + } +} diff --git a/lib/errorlogger.h b/lib/errorlogger.h index 248bbf5e3..67a54dd48 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -20,6 +20,7 @@ #ifndef errorloggerH #define errorloggerH +#include #include #include #include "settings.h" @@ -140,7 +141,10 @@ public: std::string _id; }; - ErrorLogger() { } + ErrorLogger() + { + time1 = 0; + } virtual ~ErrorLogger() { } /** @@ -168,7 +172,19 @@ public: */ virtual void reportStatus(unsigned int index, unsigned int max) = 0; + /** + * Report progress. + * + * @param func function name (NULL = start command) + * @param tok current token + */ + void ReportProgress(const char func[], const Token * const tok); + static std::string callStackToString(const std::list &callStack); + +private: + /** time variable for the 'ReportProgress' */ + std::time_t time1; }; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 45f54e781..e477d4bd2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1647,6 +1647,9 @@ void Tokenizer::simplifyTypedef() bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::string &configuration) { + if (_errorLogger) + _errorLogger->ReportProgress(0, 0); + _configuration = configuration; // The "_files" vector remembers what files have been tokenized.. @@ -2673,6 +2676,9 @@ void Tokenizer::setVarId() if (tok != _tokens && !Token::Match(tok, "[,;{}(] %type%")) continue; + if (_errorLogger) + _errorLogger->ReportProgress(__FUNCTION__, tok); + // If pattern is "( %type% *|& %var% )" then check if it's a // variable declaration or a multiplication / mask if (Token::Match(tok, "( %type% *|& %var% )") && !tok->next()->isStandardType()) @@ -7851,3 +7857,5 @@ void Tokenizer::simplifyBuiltinExpect() } } + +