提交 fba1b3d9 编写于 作者: Y Yinan Xu

emu: add --no-snapshot option to disable saving snapshots

上级 c0bc6fd8
......@@ -22,6 +22,7 @@ static inline void print_help(const char *file) {
printf(" -b, --log-begin=NUM display log from NUM th cycle\n");
printf(" -e, --log-end=NUM stop display log at NUM th cycle\n");
printf(" --load-snapshot=PATH load snapshot from PATH\n");
printf(" --no-snapshot disable saving snapshots\n");
printf(" --dump-wave dump waveform when log is enabled\n");
printf(" -h, --help print program help info\n");
printf("\n");
......@@ -33,6 +34,7 @@ inline EmuArgs parse_args(int argc, const char *argv[]) {
const struct option long_options[] = {
{ "load-snapshot", 1, NULL, 0 },
{ "dump-wave", 0, NULL, 0 },
{ "no-snapshot", 0, NULL, 0 },
{ "seed", 1, NULL, 's' },
{ "max-cycles", 1, NULL, 'C' },
{ "max-instr", 1, NULL, 'I' },
......@@ -51,6 +53,7 @@ inline EmuArgs parse_args(int argc, const char *argv[]) {
switch (long_index) {
case 0: args.snapshot_path = optarg; continue;
case 1: args.enable_waveform = true; continue;
case 2: args.enable_snapshot = false; continue;
}
// fall through
default:
......@@ -129,7 +132,7 @@ Emulator::~Emulator() {
ram_finish();
#ifdef VM_SAVABLE
if (trapCode != STATE_GOODTRAP && trapCode != STATE_LIMIT_EXCEEDED) {
if (args.enable_snapshot && trapCode != STATE_GOODTRAP && trapCode != STATE_LIMIT_EXCEEDED) {
printf("Saving snapshots to file system. Please wait.\n");
snapshot_slot[0].save();
snapshot_slot[1].save();
......@@ -321,7 +324,7 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
}
#ifdef VM_SAVABLE
static int snapshot_count = 0;
if (trapCode != STATE_GOODTRAP && t - lasttime_snapshot > 6000 * SNAPSHOT_INTERVAL) {
if (args.enable_snapshot && trapCode != STATE_GOODTRAP && t - lasttime_snapshot > 6000 * SNAPSHOT_INTERVAL) {
// save snapshot every 60s
time_t now = time(NULL);
snapshot_save(snapshot_filename(now));
......
......@@ -14,6 +14,7 @@ struct EmuArgs {
const char *image;
const char *snapshot_path;
bool enable_waveform;
bool enable_snapshot;
EmuArgs() {
seed = 0;
......@@ -24,6 +25,7 @@ struct EmuArgs {
snapshot_path = NULL;
image = NULL;
enable_waveform = false;
enable_snapshot = true;
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册