Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(difftest): include difftest-def.h in spike #81

Merged
merged 1 commit into from
Jan 1, 2025

Conversation

Tang-Haojin
Copy link
Member

Previously, we only include diffteset-def.h in difftest-related files, which causes various inconsistencies in class or struct definitions.

Take processor.h for an example. The structure or size of struct state_t is dependent on the macro definition of CONFIG_PMP_MAX_NUM in diffteset-def.h. Different CONFIG_PMP_MAX_NUM results in different struct state_t, and further results in different class processor_t.

Considering that we includes processor.h and uses class processor_t in both difftest/difftest.cc and riscv/sim.cc, where the first difftest/difftest.cc has CONFIG_PMP_MAX_NUM defined but the second riscv/sim.cc not. If a variable of class processor_t is defined in one file and is used in another one (by global variable, return value of function call, etc.), the data may corrupt.

Here are some printfs below for better explanation.

----------/nfs/home/tanghaojin/riscv-isa-sim/riscv/sim.cc----------
sizeof processor_t: 0x412d8
sizeof state_t: 0xee0
procs[0] addr: 0x769751a81010
procs[0]->state.fflags addr: 0x769751a81df8
procs[0]->VU addr: 0x769751ac21f8
----------/nfs/home/tanghaojin/riscv-isa-sim/difftest/difftest.cc----------
sizeof processor_t: 0x40fd8
sizeof state_t: 0xbe0
procs[0] addr: 0x769751a81010
procs[0]->state.fflags addr: 0x769751a81af8
procs[0]->VU addr: 0x769751ac1ef8

This is a temporary fixup and a better way is to use a "spike-way" (autoconf / automake / ./configure) to manage difftest codes with spike.

@poemonsense poemonsense merged commit a8639ee into difftest Jan 1, 2025
18 checks passed
@poemonsense poemonsense deleted the fix-diff-class-def-in-diff-file branch January 1, 2025 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants