From 9fcafefe27fcada26aca5a7b9ecb7b3f80fb0803 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 29 Nov 2021 02:09:05 -0800 Subject: [PATCH] arch-sparc: Fix a bug in SparcNativeTrace::check. This method is responsible for comparing gem5's state against the state of the real process. When checking the value of NPC, it accessed the value of nnpc() by calling pc.nnpc(), but did not actually update regVal with it, so the comparison was between the value from the real process and npc(). It's mildly confusing that nnpc is compared against npc, and npc against pc, but that's because of what the state looks like in the real process when single stepping through it with ptrace. You can actually see where this bug was introduced if you look at the change which created the PCState types originally. There, you can see how regVal was set using a method of the ThreadContext, but after that change the value is only accessed and not actually used. Change-Id: I0f0101db5f807640b8d25fef6448081d9cfa0213 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53363 Reviewed-by: Daniel Carvalho Reviewed-by: Boris Shingarov Maintainer: Gabe Black Tested-by: kokoro --- src/arch/sparc/nativetrace.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arch/sparc/nativetrace.cc b/src/arch/sparc/nativetrace.cc index ff2b8f1a1c..f10d0ad64f 100644 --- a/src/arch/sparc/nativetrace.cc +++ b/src/arch/sparc/nativetrace.cc @@ -79,7 +79,7 @@ Trace::SparcNativeTrace::check(NativeTraceRecord *record) // NPC read(&realRegVal, sizeof(realRegVal)); realRegVal = betoh(realRegVal); - pc.nnpc(); + regVal = pc.nnpc(); checkReg("npc", regVal, realRegVal); // CCR