From 898898096685eacff14200f4483c765157dee170 Mon Sep 17 00:00:00 2001 From: tracer-ysyx Date: Wed, 20 Mar 2024 18:47:11 +0800 Subject: [PATCH] =?UTF-8?q?>=20compile=20NEMU=20ysyx=5F22040000=20?= =?UTF-8?q?=E6=9D=8E=E5=BF=83=E6=9D=A8=20Linux=20calcite=206.6.19=20#1-Nix?= =?UTF-8?q?OS=20SMP=20PREEMPT=5FDYNAMIC=20Fri=20Mar=20=201=2012:35:11=20UT?= =?UTF-8?q?C=202024=20x86=5F64=20GNU/Linux=20=2018:47:11=20=20up=20=20=205?= =?UTF-8?q?:53,=20=202=20users,=20=20load=20average:=200.48,=200.46,=200.4?= =?UTF-8?q?6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nemu/include/ftrace.h | 4 ++-- nemu/src/isa/riscv32/inst.c | 6 +++--- nemu/src/utils/ftrace.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nemu/include/ftrace.h b/nemu/include/ftrace.h index f41f984..9fcf28a 100644 --- a/nemu/include/ftrace.h +++ b/nemu/include/ftrace.h @@ -10,8 +10,8 @@ typedef struct { } func_t; extern func_t *func_table; -void ftrace_call(vaddr_t); -void ftrace_return(vaddr_t); +void ftrace_call(vaddr_t, vaddr_t); +void ftrace_return(vaddr_t, vaddr_t); // const char *get_func_name(vaddr_t addr); #endif diff --git a/nemu/src/isa/riscv32/inst.c b/nemu/src/isa/riscv32/inst.c index f2edfdc..54b9044 100644 --- a/nemu/src/isa/riscv32/inst.c +++ b/nemu/src/isa/riscv32/inst.c @@ -64,9 +64,9 @@ static void ftrace(Decode *s, int rd, vaddr_t dst) { uint32_t i = s->isa.inst.val; int rs1 = BITS(i, 19, 15); if(rs1 == 1 && rd == 0) { - ftrace_return(dst); + ftrace_return(s->pc, dst); } else { - ftrace_call(dst); + ftrace_call(s->pc, dst); } } @@ -85,7 +85,7 @@ static int decode_exec(Decode *s) { INSTPAT("??????? ????? ????? ??? ????? 01101 11", lui , U, R(rd) = imm); INSTPAT("??????? ????? ????? ??? ????? 00101 11", auipc , U, R(rd) = s->pc + imm); - INSTPAT("??????? ????? ????? ??? ????? 11011 11", jal , J, do {s->dnpc = s->pc + imm; R(rd) = s->pc + 4; ftrace_call(s->pc + imm); } while(0)); + INSTPAT("??????? ????? ????? ??? ????? 11011 11", jal , J, do {s->dnpc = s->pc + imm; R(rd) = s->pc + 4; ftrace_call(s->pc, s->pc + imm); } while(0)); INSTPAT("??????? ????? ????? ??? ????? 11001 11", jalr , I, do {s->dnpc = src1 + imm; R(rd) = s->pc + 4; ftrace(s, rd, src1 + imm); } while(0)); INSTPAT("??????? ????? ????? 000 ????? 11000 11", beq , B, do_branch(s, src1 == src2, imm)); INSTPAT("??????? ????? ????? 001 ????? 11000 11", bne , B, do_branch(s, src1 != src2, imm)); diff --git a/nemu/src/utils/ftrace.c b/nemu/src/utils/ftrace.c index eeb0ef9..3b972c3 100644 --- a/nemu/src/utils/ftrace.c +++ b/nemu/src/utils/ftrace.c @@ -99,11 +99,11 @@ failed_nosym: return; } -void ftrace_call(vaddr_t addr) { +void ftrace_call(vaddr_t pc, vaddr_t addr) { printf("[FTRACE] call [%s@0x%x]\n", get_func_name(addr), addr); } -void ftrace_return(vaddr_t addr) { +void ftrace_return(vaddr_t pc, vaddr_t addr) { printf("[FTRACE] ret [%s@0x%x]\n", get_func_name(addr), addr); }