x86,misc: add additional info on faulting X86 instruction, fetched PC
authorMatt Sinclair <mattdsinclair@gmail.com>
Thu, 7 Dec 2017 01:29:11 +0000 (20:29 -0500)
committerMatt Sinclair <mattdsinclair@gmail.com>
Fri, 8 Dec 2017 04:05:58 +0000 (04:05 +0000)
Print faulting instruction for unmapped address panic in faults.cc
and print extra info about corresponding fetched PC in base.cc.

Change-Id: Id9e15d3e88df2ad6b809fb3cf9f6ae97e9e97e0f
Reviewed-on: https://gem5-review.googlesource.com/6461
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/arch/x86/faults.cc
src/cpu/simple/base.cc

index 4198bcc7cf444c59cd396c9750ca82eb0bb727d0..093926d362c3dda8a9aec6122e79435cc3376fd8 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "arch/x86/generated/decoder.hh"
 #include "arch/x86/isa_traits.hh"
+#include "base/loader/symtab.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "debug/Faults.hh"
@@ -161,7 +162,15 @@ namespace X86ISA
                 modeStr = "write";
             else
                 modeStr = "read";
-            panic("Tried to %s unmapped address %#x.\n", modeStr, addr);
+
+            // print information about what we are panic'ing on
+            if (!inst) {
+                panic("Tried to %s unmapped address %#x.\n", modeStr, addr);
+            } else {
+                panic("Tried to %s unmapped address %#x.\nPC: %#x, Instr: %s",
+                      modeStr, addr, tc->pcState().pc(),
+                      inst->disassemble(tc->pcState().pc(), debugSymbolTable));
+            }
         }
     }
 
index 5c8eba6ef25de14131d4f2e2c7152a0f824e90dd..1f12afbf06a52b866d6335ebf657664701981891 100644 (file)
@@ -475,13 +475,13 @@ BaseSimpleCPU::setupFetchRequest(Request *req)
     SimpleThread* thread = t_info.thread;
 
     Addr instAddr = thread->instAddr();
+    Addr fetchPC = (instAddr & PCMask) + t_info.fetchOffset;
 
     // set up memory request for instruction fetch
-    DPRINTF(Fetch, "Fetch: PC:%08p\n", instAddr);
+    DPRINTF(Fetch, "Fetch: Inst PC:%08p, Fetch PC:%08p\n", instAddr, fetchPC);
 
-    Addr fetchPC = (instAddr & PCMask) + t_info.fetchOffset;
-    req->setVirt(0, fetchPC, sizeof(MachInst), Request::INST_FETCH, instMasterId(),
-            instAddr);
+    req->setVirt(0, fetchPC, sizeof(MachInst), Request::INST_FETCH,
+                 instMasterId(), instAddr);
 }