diff options
author | Rupert Swarbrick <rswarbrick@gmail.com> | 2020-03-27 10:25:20 +0000 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-04-05 22:35:36 -0700 |
commit | 414cf9ae675e5c437528abfcb758f1b127d86dce (patch) | |
tree | 4f41c41466be285e981ae0ae30401279a7b36cc1 /spike_main | |
parent | 59847b98f014d1f672fa6e26f9f288ffa72ead7c (diff) | |
download | spike-414cf9ae675e5c437528abfcb758f1b127d86dce.zip spike-414cf9ae675e5c437528abfcb758f1b127d86dce.tar.gz spike-414cf9ae675e5c437528abfcb758f1b127d86dce.tar.bz2 |
Write execution logs to a named log file (#409)
This patch adds a --log argument to spike. If not given, the behaviour
is unchanged: messages logging execution of instructions and (if
commit logging is enabled) commits go to stderr.
If --log=P is given, Spike now writes these messages to a log file at
the path P. This is nice, because they are no longer tangled up with
other errors and warnings.
The code is mostly plumbing: passing a FILE* object through to the
functions that were using stderr. I've written a simple "log_file_t"
class, which opens a log file if necessary and yields it or stderr.
Diffstat (limited to 'spike_main')
-rw-r--r-- | spike_main/spike-log-parser.cc | 2 | ||||
-rw-r--r-- | spike_main/spike.cc | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/spike_main/spike-log-parser.cc b/spike_main/spike-log-parser.cc index 5de6220..d174afc 100644 --- a/spike_main/spike-log-parser.cc +++ b/spike_main/spike-log-parser.cc @@ -27,7 +27,7 @@ int main(int argc, char** argv) parser.option(0, "isa", 1, [&](const char* s){isa = s;}); parser.parse(argv); - processor_t p(isa, DEFAULT_PRIV, DEFAULT_VARCH, 0, 0); + processor_t p(isa, DEFAULT_PRIV, DEFAULT_VARCH, 0, 0, false, nullptr); if (extension) { p.register_extension(extension()); } diff --git a/spike_main/spike.cc b/spike_main/spike.cc index 1474a4c..31c0cd7 100644 --- a/spike_main/spike.cc +++ b/spike_main/spike.cc @@ -144,6 +144,7 @@ int main(int argc, char** argv) std::unique_ptr<cache_sim_t> l2; bool log_cache = false; bool log_commits = false; + const char *log_path = nullptr; std::function<extension_t*()> extension; const char* initrd = NULL; const char* isa = DEFAULT_ISA; @@ -267,7 +268,10 @@ int main(int argc, char** argv) [&](const char* s){dm_config.support_abstract_csr_access = false;}); parser.option(0, "dm-no-halt-groups", 0, [&](const char* s){dm_config.support_haltgroups = false;}); - parser.option(0, "log-commits", 0, [&](const char* s){log_commits = true;}); + parser.option(0, "log-commits", 0, + [&](const char* s){log_commits = true;}); + parser.option(0, "log", 1, + [&](const char* s){log_path = s;}); auto argv1 = parser.parse(argv); std::vector<std::string> htif_args(argv1, (const char*const*)argv + argc); @@ -291,7 +295,7 @@ int main(int argc, char** argv) sim_t s(isa, priv, varch, nprocs, halted, real_time_clint, initrd_start, initrd_end, start_pc, mems, plugin_devices, htif_args, - std::move(hartids), dm_config); + std::move(hartids), dm_config, log_path); std::unique_ptr<remote_bitbang_t> remote_bitbang((remote_bitbang_t *) NULL); std::unique_ptr<jtag_dtm_t> jtag_dtm( new jtag_dtm_t(&s.debug_module, dmi_rti)); @@ -318,9 +322,8 @@ int main(int argc, char** argv) } s.set_debug(debug); - s.set_log(log); + s.configure_log(log, log_commits); s.set_histogram(histogram); - s.set_log_commits(log_commits); auto return_code = s.run(); |