Revert "Merge remote-tracking branch 'origin/eddie/shregmap_improve' into xc7mux"
[yosys.git] / kernel / log.cc
index 0ee2170a062bef470211acdf6cecb23390f755b6..a7820950c9dcdc3f4ea45b240931af5c3d7b02b6 100644 (file)
@@ -56,6 +56,10 @@ int log_verbose_level;
 string log_last_error;
 void (*log_error_atexit)() = NULL;
 
+int log_make_debug = 0;
+int log_force_debug = 0;
+int log_debug_suppressed = 0;
+
 vector<int> header_count;
 pool<RTLIL::IdString> log_id_cache;
 vector<shared_str> string_buf;
@@ -92,6 +96,9 @@ void logv(const char *format, va_list ap)
                format++;
        }
 
+       if (log_make_debug && !ys_debug(1))
+               return;
+
        std::string str = vstringf(format, ap);
 
        if (str.empty())
@@ -196,7 +203,11 @@ void logv_header(RTLIL::Design *design, const char *format, va_list ap)
        if (log_hdump.count(header_id) && design != nullptr)
                for (auto &filename : log_hdump.at(header_id)) {
                        log("Dumping current design to '%s'.\n", filename.c_str());
+                       if (yosys_xtrace)
+                               IdString::xtrace_db_dump();
                        Pass::call(design, {"dump", "-o", filename});
+                       if (yosys_xtrace)
+                               log("#X# -- end of dump --\n");
                }
 
        if (pop_errfile)
@@ -219,6 +230,9 @@ static void logv_warning_with_prefix(const char *prefix,
        }
        else
        {
+               int bak_log_make_debug = log_make_debug;
+               log_make_debug = 0;
+
                for (auto &re : log_werror_regexes)
                        if (std::regex_search(message, re))
                                log_error("%s",  message.c_str());
@@ -243,6 +257,7 @@ static void logv_warning_with_prefix(const char *prefix,
                }
 
                log_warnings_count++;
+               log_make_debug = bak_log_make_debug;
        }
 }
 
@@ -262,11 +277,22 @@ void log_file_warning(const std::string &filename, int lineno,
        va_list ap;
        va_start(ap, format);
        std::string prefix = stringf("%s:%d: Warning: ",
-                                    filename.c_str(), lineno);
+                       filename.c_str(), lineno);
        logv_warning_with_prefix(prefix.c_str(), format, ap);
        va_end(ap);
 }
 
+void log_file_info(const std::string &filename, int lineno,
+                      const char *format, ...)
+{
+       va_list ap;
+       va_start(ap, format);
+       std::string fmt = stringf("%s:%d: Info: %s",
+                       filename.c_str(), lineno, format);
+       logv(fmt.c_str(), ap);
+       va_end(ap);
+}
+
 YS_ATTRIBUTE(noreturn)
 static void logv_error_with_prefix(const char *prefix,
                                    const char *format, va_list ap)
@@ -274,6 +300,9 @@ static void logv_error_with_prefix(const char *prefix,
 #ifdef EMSCRIPTEN
        auto backup_log_files = log_files;
 #endif
+       int bak_log_make_debug = log_make_debug;
+       log_make_debug = 0;
+       log_suppressed();
 
        if (log_errfile != NULL)
                log_files.push_back(log_errfile);
@@ -287,6 +316,8 @@ static void logv_error_with_prefix(const char *prefix,
        log("%s%s", prefix, log_last_error.c_str());
        log_flush();
 
+       log_make_debug = bak_log_make_debug;
+
        if (log_error_atexit)
                log_error_atexit();