@@ -38,6 +38,7 @@ static void help(int exit_code = 1)
3838 fprintf (stderr, " -s Command I/O via socket (use with -d)\n " );
3939#endif
4040 fprintf (stderr, " -h, --help Print this help message\n " );
41+ fprintf (stderr, " --version Print spike version\n " );
4142 fprintf (stderr, " --halted Start halted, allowing a debugger to connect\n " );
4243 fprintf (stderr, " --log=<name> File name for option -l\n " );
4344 fprintf (stderr, " --debug-cmd=<name> Read commands from file (use with -d)\n " );
@@ -94,6 +95,12 @@ static void suggest_help()
9495 exit (1 );
9596}
9697
98+ static void state_version ()
99+ {
100+ fprintf (stdout, " Spike RISC-V ISA Simulator " SPIKE_VERSION " \n\n " );
101+ exit (0 );
102+ }
103+
97104static bool check_file_exists (const char *fileName)
98105{
99106 std::ifstream infile (fileName);
@@ -387,6 +394,7 @@ int main(int argc, char** argv)
387394 parser.option (0 , " l2" , 1 , [&](const char * s){l2.reset (cache_sim_t::construct (s, " L2$" ));});
388395 parser.option (0 , " big-endian" , 0 , [&](const char UNUSED *s){cfg.endianness = endianness_big;});
389396 parser.option (0 , " misaligned" , 0 , [&](const char UNUSED *s){cfg.misaligned = true ;});
397+ parser.option (0 , " version" , 0 , [&](const char UNUSED *s){state_version ();});
390398 parser.option (0 , " log-cache-miss" , 0 , [&](const char UNUSED *s){log_cache = true ;});
391399 parser.option (0 , " isa" , 1 , [&](const char * s){cfg.isa = s;});
392400 parser.option (0 , " pmpregions" , 1 , [&](const char * s){cfg.pmpregions = atoul_safe (s);});
0 commit comments