> compile NEMU

ysyx_22040000 李心杨
Linux calcite 6.6.19 #1-NixOS SMP PREEMPT_DYNAMIC Fri Mar  1 12:35:11 UTC 2024 x86_64 GNU/Linux
 15:46:28  up   5:22,  2 users,  load average: 0.44, 0.49, 0.45
This commit is contained in:
tracer-ysyx 2024-03-13 15:46:28 +08:00 committed by xinyangli
parent 58985894f6
commit 08e1837cbe
2 changed files with 10 additions and 12 deletions

View file

@ -23,8 +23,6 @@ typedef struct Decode {
vaddr_t snpc; // static next pc
vaddr_t dnpc; // dynamic next pc
ISADecodeInfo isa;
IFDEF(CONFIG_ITRACE, char logbuf[CONFIG_ITRACE_BUFFER][128]);
IFDEF(CONFIG_ITRACE, int logbuf_rear);
} Decode;
// --- pattern matching mechanism ---

View file

@ -30,14 +30,17 @@ uint64_t g_nr_guest_inst = 0;
static uint64_t g_timer = 0; // unit: us
static bool g_print_step = false;
IFDEF(CONFIG_ITRACE, char logbuf[CONFIG_ITRACE_BUFFER][128]);
IFDEF(CONFIG_ITRACE, int logbuf_rear);
void device_update();
bool wp_eval_all();
static void trace_and_difftest(Decode *_this, vaddr_t dnpc) {
#ifdef CONFIG_ITRACE_COND
if (ITRACE_COND) { log_write("%s\n", _this->logbuf[_this->logbuf_rear]); }
if (ITRACE_COND) { log_write("%s\n", logbuf[logbuf_rear]); }
#endif
if (g_print_step) { IFDEF(CONFIG_ITRACE, puts(_this->logbuf[_this->logbuf_rear])); }
if (g_print_step) { IFDEF(CONFIG_ITRACE, puts(logbuf[logbuf_rear])); }
IFDEF(CONFIG_DIFFTEST, difftest_step(_this->pc, dnpc));
}
@ -47,9 +50,9 @@ static void exec_once(Decode *s, vaddr_t pc) {
isa_exec_once(s);
cpu.pc = s->dnpc;
#ifdef CONFIG_ITRACE
s->logbuf_rear = (s->logbuf_rear + 1) % CONFIG_ITRACE_BUFFER;
char *p = s->logbuf[s->logbuf_rear];
p += snprintf(p, sizeof(s->logbuf), FMT_WORD ":", s->pc);
logbuf_rear = (logbuf_rear + 1) % CONFIG_ITRACE_BUFFER;
char *p = logbuf[logbuf_rear];
p += snprintf(p, sizeof(logbuf), FMT_WORD ":", s->pc);
int ilen = s->snpc - s->pc;
int i;
uint8_t *inst = (uint8_t *)&s->isa.inst.val;
@ -65,7 +68,7 @@ static void exec_once(Decode *s, vaddr_t pc) {
#ifndef CONFIG_ISA_loongarch32r
void disassemble(char *str, int size, uint64_t pc, uint8_t *code, int nbyte);
disassemble(p, s->logbuf[s->logbuf_rear] + sizeof(s->logbuf) - p,
disassemble(p, logbuf[logbuf_rear] + sizeof(logbuf[logbuf_rear]) - p,
MUXDEF(CONFIG_ISA_x86, s->snpc, s->pc), (uint8_t *)&s->isa.inst.val, ilen);
#else
p[0] = '\0'; // the upstream llvm does not support loongarch32r
@ -75,15 +78,12 @@ static void exec_once(Decode *s, vaddr_t pc) {
static void execute(uint64_t n) {
Decode s;
#ifdef CONFIG_ITRACE
memset(s.logbuf, 0, CONFIG_ITRACE_BUFFER * 128 * sizeof(char));
#endif
for (;n > 0; n --) {
exec_once(&s, cpu.pc);
g_nr_guest_inst ++;
trace_and_difftest(&s, cpu.pc);
if (wp_eval_all()) {
puts(s.logbuf[s.logbuf_rear]);
puts(logbuf[logbuf_rear]);
break;
}
if (nemu_state.state != NEMU_RUNNING) break;