Added 'trace' option
This commit is contained in:
parent
e7b521c589
commit
c3fa088a38
@ -676,8 +676,11 @@ void cpu_loop(rv32_cpu_t* cpu)
|
||||
instruction_t instruction;
|
||||
cpu_decode(raw_instruction, &instruction);
|
||||
|
||||
printf("0x%x: ", cpu->pc);
|
||||
cpu_print_instruction(&instruction);
|
||||
if(trace)
|
||||
{
|
||||
printf("0x%x: ", cpu->pc);
|
||||
cpu_print_instruction(&instruction);
|
||||
}
|
||||
|
||||
// Execute
|
||||
cpu_execute(cpu, &instruction);
|
||||
|
12
src/option.c
12
src/option.c
@ -8,6 +8,7 @@
|
||||
uint64_t memory_size = 512 * 1024 * 1024;
|
||||
char* file_path;
|
||||
bool gdbstub = false;
|
||||
bool trace = false;
|
||||
|
||||
static void print_usage();
|
||||
static void print_help();
|
||||
@ -100,6 +101,11 @@ void parse_options(int argc, char** argv)
|
||||
gdbstub = true;
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
{
|
||||
trace = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
fprintf(stderr, "Error: Unknown short option -%c\n", argv[i][k]);
|
||||
@ -161,6 +167,11 @@ static int parse_long_option(char* str, char* argq)
|
||||
gdbstub = true;
|
||||
return 0;
|
||||
}
|
||||
else if(strcmp(str, "trace") == 0)
|
||||
{
|
||||
trace = true;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Error: Unknown long option " OPTION_SEPARATOR OPTION_SEPARATOR "%s\n", str);
|
||||
@ -181,6 +192,7 @@ static void print_help()
|
||||
printf(" " OPTION_SEPARATOR "h, " OPTION_SEPARATOR "?, --help\t\tPrint this help message\n");
|
||||
printf(" " OPTION_SEPARATOR "v, --version\t\t\tPrint version information\n");
|
||||
printf(" " OPTION_SEPARATOR "m, --memory\t\t\tSet the simulated memory size, in MiB (max 4096)\n");
|
||||
printf(" " OPTION_SEPARATOR "t, --trace\t\t\tTrace executed instructions in stdout\n");
|
||||
printf(" " OPTION_SEPARATOR "s, --gdb-stub\t\tLaunch a gdb stub server (remote gdb debugging)\n");
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ extern char* CURRENT_NAME;
|
||||
extern size_t memory_size;
|
||||
extern char* file_path;
|
||||
extern bool gdbstub;
|
||||
extern bool trace;
|
||||
void parse_options(int argc, char** argv);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user