NJU-ProjectN / nemu

NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching
Other
858 stars 184 forks source link

question about the difftest code #66

Closed fuxinyuan1998 closed 1 year ago

fuxinyuan1998 commented 1 year ago

I have a question about the difftest in the file src/isa/riscv64/local-include/reg.h static inline const char* reg_name(int idx, int width) { extern const char* regs[]; return regs[check_reg_idx(idx)]; } why there is a parameter 'width' not used

fuxinyuan1998 commented 1 year ago

and I get an error which is make[2]: Circular libriscv.so <- libriscv.so dependency dropped. when I turn on the difftest option. when I excute 'make run', the program has been excuted successfully. but when I debug it, the program will trigger the assertion of 'dlopen', and I have no idea about this. Could you give me some tips or hints? image

sashimi-yzh commented 1 year ago

Does ref_so_file exist? If not, please try to check why. The Makefiles should contain rules to build ref_so_file.

For the width parameter, it is used in x86. So you can ignore it in riscv64.

fuxinyuan1998 commented 1 year ago

I believe I am sure the file exits and the path is right and I write a program to test it. the test open it successfully but it cant work in nemu. here is the program.

`#include

include

include

include

include

define LIB_CALCULATE_PATH "./riscv64-spike-so"

typedef int (*CAC_FUNC)(int, int);

int main() { void handle; char error; CAC_FUNC cac_func = NULL; handle = dlopen(LIB_CALCULATE_PATH, RTLD_LAZY); if(!handle){ fprintf(stderr, "%s\n", dlerror()); exit(EXIT_FAILURE); }else{ printf("successfull!\n"); } assert(handle); }`

sashimi-yzh commented 1 year ago

What does dlerror() report in NEMU?

fuxinyuan1998 commented 1 year ago

when I debug it with gdb, the handle gets 0x0 and dlerror report "no such file or directory" image but when I excute make run, there is nothing wrong happend but the "difftest" function has not been implemented image

sashimi-yzh commented 1 year ago

According to the message reported by dlerror(), it seems that there is a trailing space in the ref_so_file string. You may remove it and retry.

fuxinyuan1998 commented 1 year ago

Thank you pretty much and I solve it. Thank you for your reply again Dr.