[lldb][ARM] Print mismatched registers in emulation tests
authorDavid Spickett <david.spickett@linaro.org>
Fri, 22 Jul 2022 14:38:03 +0000 (14:38 +0000)
committerDavid Spickett <david.spickett@linaro.org>
Tue, 26 Jul 2022 08:28:27 +0000 (08:28 +0000)
Also correct the test failed message. It implies that what
it's done is compare the 'before' and 'ater' states from the
test input.

Except that that's the whole point of the test, that the state changes.
It should tell you that it compared the result of the emulation to the
'after'.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D130464

lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h

index 5bc745c..b00a177 100644 (file)
@@ -14453,10 +14453,10 @@ bool EmulateInstructionARM::TestEmulation(Stream *out_stream, ArchSpec &arch,
     return false;
   }
 
-  success = before_state.CompareState(after_state);
+  success = before_state.CompareState(after_state, out_stream);
   if (!success)
     out_stream->Printf(
-        "TestEmulation:  'before' and 'after' states do not match.\n");
+        "TestEmulation:  State after emulation does not match 'after' state.\n");
 
   return success;
 }
index bc5a7f4..6ac2f8a 100644 (file)
@@ -251,22 +251,32 @@ bool EmulationStateARM::WritePseudoRegister(
                                                 reg_value.GetAsUInt64());
 }
 
-bool EmulationStateARM::CompareState(EmulationStateARM &other_state) {
+bool EmulationStateARM::CompareState(EmulationStateARM &other_state,
+                                     Stream *out_stream) {
   bool match = true;
 
   for (int i = 0; match && i < 17; ++i) {
-    if (m_gpr[i] != other_state.m_gpr[i])
+    if (m_gpr[i] != other_state.m_gpr[i]) {
       match = false;
+      out_stream->Printf("r%d: 0x%x != 0x%x\n", i, m_gpr[i],
+                         other_state.m_gpr[i]);
+    }
   }
 
   for (int i = 0; match && i < 32; ++i) {
-    if (m_vfp_regs.s_regs[i] != other_state.m_vfp_regs.s_regs[i])
+    if (m_vfp_regs.s_regs[i] != other_state.m_vfp_regs.s_regs[i]) {
       match = false;
+      out_stream->Printf("s%d: 0x%x != 0x%x\n", i, m_vfp_regs.s_regs[i],
+                         other_state.m_vfp_regs.s_regs[i]);
+    }
   }
 
   for (int i = 0; match && i < 16; ++i) {
-    if (m_vfp_regs.d_regs[i] != other_state.m_vfp_regs.d_regs[i])
+    if (m_vfp_regs.d_regs[i] != other_state.m_vfp_regs.d_regs[i]) {
       match = false;
+      out_stream->Printf("d%d: 0x%lx != 0x%lx\n", i + 16, m_vfp_regs.d_regs[i],
+                         other_state.m_vfp_regs.d_regs[i]);
+    }
   }
 
   return match;
index b240fbb..bc885da 100644 (file)
@@ -36,7 +36,8 @@ public:
 
   bool LoadStateFromDictionary(lldb_private::OptionValueDictionary *test_data);
 
-  bool CompareState(EmulationStateARM &other_state);
+  bool CompareState(EmulationStateARM &other_state,
+                    lldb_private::Stream *out_stream);
 
   static size_t
   ReadPseudoMemory(lldb_private::EmulateInstruction *instruction, void *baton,