mirror of https://github.com/YosysHQ/yosys.git
Added "yosys -W regex"
This commit is contained in:
parent
f144adec58
commit
a0dff87a57
|
@ -218,6 +218,9 @@ int main(int argc, char **argv)
|
||||||
printf(" yosys_dump_<header_id>.il is used as filename if none is specified.\n");
|
printf(" yosys_dump_<header_id>.il is used as filename if none is specified.\n");
|
||||||
printf(" Use 'ALL' as <header_id> to dump at every header.\n");
|
printf(" Use 'ALL' as <header_id> to dump at every header.\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
printf(" -W regex\n");
|
||||||
|
printf(" print a warning for all log messages matching the regex \n");
|
||||||
|
printf("\n");
|
||||||
printf(" -V\n");
|
printf(" -V\n");
|
||||||
printf(" print version information and exit\n");
|
printf(" print version information and exit\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -238,7 +241,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:D:")) != -1)
|
while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:W:D:")) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
|
@ -320,6 +323,12 @@ int main(int argc, char **argv)
|
||||||
scriptfile = optarg;
|
scriptfile = optarg;
|
||||||
scriptfile_tcl = true;
|
scriptfile_tcl = true;
|
||||||
break;
|
break;
|
||||||
|
case 'W':
|
||||||
|
log_warn_regexes.push_back(std::regex(optarg,
|
||||||
|
std::regex_constants::nosubs |
|
||||||
|
std::regex_constants::optimize |
|
||||||
|
std::regex_constants::egrep));
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
{
|
{
|
||||||
auto args = split_tokens(optarg, ":");
|
auto args = split_tokens(optarg, ":");
|
||||||
|
|
|
@ -41,6 +41,7 @@ YOSYS_NAMESPACE_BEGIN
|
||||||
std::vector<FILE*> log_files;
|
std::vector<FILE*> log_files;
|
||||||
std::vector<std::ostream*> log_streams;
|
std::vector<std::ostream*> log_streams;
|
||||||
std::map<std::string, std::set<std::string>> log_hdump;
|
std::map<std::string, std::set<std::string>> log_hdump;
|
||||||
|
std::vector<std::regex> log_warn_regexes;
|
||||||
bool log_hdump_all = false;
|
bool log_hdump_all = false;
|
||||||
FILE *log_errfile = NULL;
|
FILE *log_errfile = NULL;
|
||||||
SHA1 *log_hasher = NULL;
|
SHA1 *log_hasher = NULL;
|
||||||
|
@ -136,6 +137,32 @@ void logv(const char *format, va_list ap)
|
||||||
|
|
||||||
for (auto f : log_streams)
|
for (auto f : log_streams)
|
||||||
*f << str;
|
*f << str;
|
||||||
|
|
||||||
|
static std::string linebuffer;
|
||||||
|
static bool log_warn_regex_recusion_guard = false;
|
||||||
|
|
||||||
|
if (!log_warn_regex_recusion_guard)
|
||||||
|
{
|
||||||
|
log_warn_regex_recusion_guard = true;
|
||||||
|
|
||||||
|
if (log_warn_regexes.empty())
|
||||||
|
{
|
||||||
|
linebuffer.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
linebuffer += str;
|
||||||
|
|
||||||
|
if (!linebuffer.empty() && linebuffer.back() == '\n') {
|
||||||
|
for (auto &re : log_warn_regexes)
|
||||||
|
if (std::regex_search(linebuffer, re))
|
||||||
|
log_warning("Found log message matching -W regex:\n%s", str.c_str());
|
||||||
|
linebuffer.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log_warn_regex_recusion_guard = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logv_header(RTLIL::Design *design, const char *format, va_list ap)
|
void logv_header(RTLIL::Design *design, const char *format, va_list ap)
|
||||||
|
@ -262,8 +289,12 @@ void log_cmd_error(const char *format, ...)
|
||||||
|
|
||||||
void log_spacer()
|
void log_spacer()
|
||||||
{
|
{
|
||||||
while (log_newline_count < 2)
|
while (log_newline_count < 2) {
|
||||||
|
int old_log_newline_count = log_newline_count;
|
||||||
log("\n");
|
log("\n");
|
||||||
|
if (old_log_newline_count >= log_newline_count)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_push()
|
void log_push()
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define LOG_H
|
#define LOG_H
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
|
@ -48,6 +49,7 @@ struct log_cmd_error_exception { };
|
||||||
extern std::vector<FILE*> log_files;
|
extern std::vector<FILE*> log_files;
|
||||||
extern std::vector<std::ostream*> log_streams;
|
extern std::vector<std::ostream*> log_streams;
|
||||||
extern std::map<std::string, std::set<std::string>> log_hdump;
|
extern std::map<std::string, std::set<std::string>> log_hdump;
|
||||||
|
extern std::vector<std::regex> log_warn_regexes;
|
||||||
extern bool log_hdump_all;
|
extern bool log_hdump_all;
|
||||||
extern FILE *log_errfile;
|
extern FILE *log_errfile;
|
||||||
extern SHA1 *log_hasher;
|
extern SHA1 *log_hasher;
|
||||||
|
|
Loading…
Reference in New Issue