Skip to content

Adding version display option with --version #1897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions spike_main/spike.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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=<name> File name for option -l\n");
fprintf(stderr, " --debug-cmd=<name> Read commands from file (use with -d)\n");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);});
Expand Down