> 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 snpc; // static next pc
vaddr_t dnpc; // dynamic next pc vaddr_t dnpc; // dynamic next pc
ISADecodeInfo isa; ISADecodeInfo isa;
IFDEF(CONFIG_ITRACE, char logbuf[CONFIG_ITRACE_BUFFER][128]);
IFDEF(CONFIG_ITRACE, int logbuf_rear);
} Decode; } Decode;
// --- pattern matching mechanism --- // --- 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 uint64_t g_timer = 0; // unit: us
static bool g_print_step = false; static bool g_print_step = false;
IFDEF(CONFIG_ITRACE, char logbuf[CONFIG_ITRACE_BUFFER][128]);
IFDEF(CONFIG_ITRACE, int logbuf_rear);
void device_update(); void device_update();
bool wp_eval_all(); bool wp_eval_all();
static void trace_and_difftest(Decode *_this, vaddr_t dnpc) { static void trace_and_difftest(Decode *_this, vaddr_t dnpc) {
#ifdef CONFIG_ITRACE_COND #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 #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)); 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); isa_exec_once(s);
cpu.pc = s->dnpc; cpu.pc = s->dnpc;
#ifdef CONFIG_ITRACE #ifdef CONFIG_ITRACE
s->logbuf_rear = (s->logbuf_rear + 1) % CONFIG_ITRACE_BUFFER; logbuf_rear = (logbuf_rear + 1) % CONFIG_ITRACE_BUFFER;
char *p = s->logbuf[s->logbuf_rear]; char *p = logbuf[logbuf_rear];
p += snprintf(p, sizeof(s->logbuf), FMT_WORD ":", s->pc); p += snprintf(p, sizeof(logbuf), FMT_WORD ":", s->pc);
int ilen = s->snpc - s->pc; int ilen = s->snpc - s->pc;
int i; int i;
uint8_t *inst = (uint8_t *)&s->isa.inst.val; 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 #ifndef CONFIG_ISA_loongarch32r
void disassemble(char *str, int size, uint64_t pc, uint8_t *code, int nbyte); 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); MUXDEF(CONFIG_ISA_x86, s->snpc, s->pc), (uint8_t *)&s->isa.inst.val, ilen);
#else #else
p[0] = '\0'; // the upstream llvm does not support loongarch32r 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) { static void execute(uint64_t n) {
Decode s; Decode s;
#ifdef CONFIG_ITRACE
memset(s.logbuf, 0, CONFIG_ITRACE_BUFFER * 128 * sizeof(char));
#endif
for (;n > 0; n --) { for (;n > 0; n --) {
exec_once(&s, cpu.pc); exec_once(&s, cpu.pc);
g_nr_guest_inst ++; g_nr_guest_inst ++;
trace_and_difftest(&s, cpu.pc); trace_and_difftest(&s, cpu.pc);
if (wp_eval_all()) { if (wp_eval_all()) {
puts(s.logbuf[s.logbuf_rear]); puts(logbuf[logbuf_rear]);
break; break;
} }
if (nemu_state.state != NEMU_RUNNING) break; if (nemu_state.state != NEMU_RUNNING) break;