From 18edd1881d8574cde650eb505a1d8131a42fc5c7 Mon Sep 17 00:00:00 2001 From: "ahmed.elalfy" Date: Mon, 20 Jan 2025 07:50:30 -0800 Subject: [PATCH] Adding version display option Fixing indents to be 2 spaces instead of tabs --- spike_main/spike.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spike_main/spike.cc b/spike_main/spike.cc index 69ce2560b6..a9b3ac9b48 100644 --- a/spike_main/spike.cc +++ b/spike_main/spike.cc @@ -38,6 +38,7 @@ static void help(int exit_code = 1) fprintf(stderr, " -s Command I/O via socket (use with -d)\n"); #endif fprintf(stderr, " -h, --help Print this help message\n"); + fprintf(stderr, " --version Print spike version\n"); fprintf(stderr, " --halted Start halted, allowing a debugger to connect\n"); fprintf(stderr, " --log= File name for option -l\n"); fprintf(stderr, " --debug-cmd= Read commands from file (use with -d)\n"); @@ -94,6 +95,12 @@ static void suggest_help() exit(1); } +static void state_version() +{ + fprintf(stdout, "Spike RISC-V ISA Simulator " SPIKE_VERSION "\n\n"); + exit(0); +} + static bool check_file_exists(const char *fileName) { std::ifstream infile(fileName); @@ -387,6 +394,7 @@ int main(int argc, char** argv) parser.option(0, "l2", 1, [&](const char* s){l2.reset(cache_sim_t::construct(s, "L2$"));}); parser.option(0, "big-endian", 0, [&](const char UNUSED *s){cfg.endianness = endianness_big;}); parser.option(0, "misaligned", 0, [&](const char UNUSED *s){cfg.misaligned = true;}); + parser.option(0, "version", 0, [&](const char UNUSED *s){state_version();}); parser.option(0, "log-cache-miss", 0, [&](const char UNUSED *s){log_cache = true;}); parser.option(0, "isa", 1, [&](const char* s){cfg.isa = s;}); parser.option(0, "pmpregions", 1, [&](const char* s){cfg.pmpregions = atoul_safe(s);});