*/
#include "kernel/yosys.h"
+#include "libs/sha1/sha1.h"
#include <readline/readline.h>
#include <readline/history.h>
log("\n");
}
+ if (print_stats)
+ log_hasher = new SHA1;
+
yosys_setup();
if (optind == argc && passes_commands.size() == 0 && scriptfile.empty()) {
if (!backend_command.empty())
run_backend(output_filename, backend_command, yosys_design);
- delete yosys_design;
- yosys_design = NULL;
-
-#ifdef COVER_ACTIVE
- if (getenv("YOSYS_COVER_DIR") || getenv("YOSYS_COVER_FILE"))
- {
- char filename_buffer[4096];
- FILE *f;
-
- if (getenv("YOSYS_COVER_DIR")) {
- snprintf(filename_buffer, 4096, "%s/yosys_cover_%d_XXXXXX.txt", getenv("YOSYS_COVER_DIR"), getpid());
- f = fdopen(mkstemps(filename_buffer, 4), "w");
- } else {
- snprintf(filename_buffer, 4096, "%s", getenv("YOSYS_COVER_FILE"));
- f = fopen(filename_buffer, "a+");
- }
-
- if (f == NULL)
- log_error("Can't create coverage file `%s'.\n", filename_buffer);
-
- log("<writing coverage file \"%s\">\n", filename_buffer);
-
- for (auto &it : get_coverage_data())
- fprintf(f, "%-60s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str());
-
- fclose(f);
- }
-#endif
-
if (print_stats)
{
+ std::string hash = log_hasher->final().substr(0, 10);
+ delete log_hasher;
+ log_hasher = nullptr;
+
struct rusage ru_buffer;
getrusage(RUSAGE_SELF, &ru_buffer);
- log("\nEnd of script. Logfile hash: xxxxxxxxxx, CPU: user %.2fs system %.2fs\n",
+ log("\nEnd of script. Logfile hash: %s, CPU: user %.2fs system %.2fs\n", hash.c_str(),
ru_buffer.ru_utime.tv_sec + 1e-6 * ru_buffer.ru_utime.tv_usec,
ru_buffer.ru_stime.tv_sec + 1e-6 * ru_buffer.ru_stime.tv_usec);
- log("%s\nTime spent:", yosys_version_str);
+ log("%s\n", yosys_version_str);
int64_t total_ns = 0;
std::set<std::tuple<int64_t, int, std::string>> timedat;
}
int out_count = 0;
+ log("Time spent:");
for (auto it = timedat.rbegin(); it != timedat.rend() && out_count < 4; it++, out_count++) {
if (out_count >= 2 && (std::get<0>(*it) < 1000000000 || int(100*std::get<0>(*it) / total_ns) < 20)) {
log(", ...");
log("%s\n", out_count ? "" : " no commands executed");
}
+#ifdef COVER_ACTIVE
+ if (getenv("YOSYS_COVER_DIR") || getenv("YOSYS_COVER_FILE"))
+ {
+ char filename_buffer[4096];
+ FILE *f;
+
+ if (getenv("YOSYS_COVER_DIR")) {
+ snprintf(filename_buffer, 4096, "%s/yosys_cover_%d_XXXXXX.txt", getenv("YOSYS_COVER_DIR"), getpid());
+ f = fdopen(mkstemps(filename_buffer, 4), "w");
+ } else {
+ snprintf(filename_buffer, 4096, "%s", getenv("YOSYS_COVER_FILE"));
+ f = fopen(filename_buffer, "a+");
+ }
+
+ if (f == NULL)
+ log_error("Can't create coverage file `%s'.\n", filename_buffer);
+
+ log("<writing coverage file \"%s\">\n", filename_buffer);
+
+ for (auto &it : get_coverage_data())
+ fprintf(f, "%-60s %10d %s\n", it.second.first.c_str(), it.second.second, it.first.c_str());
+
+ fclose(f);
+ }
+#endif
+
if (call_abort)
abort();
*/
#include "kernel/yosys.h"
+#include "libs/sha1/sha1.h"
#include "backends/ilang/ilang_backend.h"
#include <sys/time.h>
std::vector<FILE*> log_files;
FILE *log_errfile = NULL;
+SHA1 *log_hasher = NULL;
+
bool log_time = false;
bool log_cmd_error_throw = false;
int log_verbose_level;
void logv(const char *format, va_list ap)
{
- if (log_time) {
- while (format[0] == '\n' && format[1] != 0) {
- format++;
- log("\n");
- }
+ while (format[0] == '\n' && format[1] != 0) {
+ log("\n");
+ format++;
+ }
+
+ std::string str = vstringf(format, ap);
+
+ if (log_hasher)
+ log_hasher->update(str);
+
+ if (log_time)
+ {
+ std::string time_str;
+
if (next_print_log || initial_tv.tv_sec == 0) {
next_print_log = false;
struct timeval tv;
}
tv.tv_sec -= initial_tv.tv_sec;
tv.tv_usec -= initial_tv.tv_usec;
- log("[%05d.%06d] ", int(tv.tv_sec), int(tv.tv_usec));
+ time_str += stringf("[%05d.%06d] ", int(tv.tv_sec), int(tv.tv_usec));
}
+
if (format[0] && format[strlen(format)-1] == '\n')
next_print_log = true;
- }
- for (auto f : log_files) {
- va_list aq;
- va_copy(aq, ap);
- vfprintf(f, format, aq);
- va_end(aq);
+ for (auto f : log_files)
+ fputs(time_str.c_str(), f);
}
+
+ for (auto f : log_files)
+ fputs(str.c_str(), f);
}
void logv_header(const char *format, va_list ap)