kvm, mem: Refactor some Event subclasses into lambdas
[gem5.git] / src / cpu / exetrace.cc
index 4c0f83a217effadc1725d29d4aa3703e622f008d..bbde89c006b029971e4dfb19e871c2ea4b06ea4c 100644 (file)
  *          Steve Raasch
  */
 
+#include "cpu/exetrace.hh"
+
 #include <iomanip>
 
+#include "arch/isa_traits.hh"
+#include "arch/utility.hh"
 #include "base/loader/symtab.hh"
+#include "config/the_isa.hh"
 #include "cpu/base.hh"
-#include "cpu/exetrace.hh"
 #include "cpu/static_inst.hh"
 #include "cpu/thread_context.hh"
+#include "debug/ExecAll.hh"
 #include "enums/OpClass.hh"
 
 using namespace std;
@@ -46,36 +51,48 @@ using namespace TheISA;
 namespace Trace {
 
 void
-Trace::ExeTracerRecord::traceInst(StaticInstPtr inst, bool ran)
+ExeTracerRecord::dumpTicks(ostream &outs)
+{
+    ccprintf(outs, "%7d: ", when);
+}
+
+void
+Trace::ExeTracerRecord::traceInst(const StaticInstPtr &inst, bool ran)
 {
     ostream &outs = Trace::output();
 
-    if (IsOn(ExecTicks))
-        ccprintf(outs, "%7d: ", when);
+    if (!Debug::ExecUser || !Debug::ExecKernel) {
+        bool in_user_mode = TheISA::inUserMode(thread);
+        if (in_user_mode && !Debug::ExecUser) return;
+        if (!in_user_mode && !Debug::ExecKernel) return;
+    }
+
+    if (Debug::ExecTicks)
+        dumpTicks(outs);
 
     outs << thread->getCpuPtr()->name() << " ";
 
-    if (IsOn(ExecSpeculative))
-        outs << (misspeculating ? "-" : "+") << " ";
+    if (Debug::ExecAsid)
+        outs << "A" << dec << TheISA::getExecutingAsid(thread) << " ";
 
-    if (IsOn(ExecThread))
+    if (Debug::ExecThread)
         outs << "T" << thread->threadId() << " : ";
 
     std::string sym_str;
     Addr sym_addr;
-    if (debugSymbolTable
-        && IsOn(ExecSymbol)
-        && debugSymbolTable->findNearestSymbol(PC, sym_str, sym_addr)) {
-        if (PC != sym_addr)
-            sym_str += csprintf("+%d", PC - sym_addr);
+    Addr cur_pc = pc.instAddr();
+    if (debugSymbolTable && Debug::ExecSymbol &&
+            (!FullSystem || !inUserMode(thread)) &&
+            debugSymbolTable->findNearestSymbol(cur_pc, sym_str, sym_addr)) {
+        if (cur_pc != sym_addr)
+            sym_str += csprintf("+%d",cur_pc - sym_addr);
         outs << "@" << sym_str;
-    }
-    else {
-        outs << "0x" << hex << PC;
+    } else {
+        outs << "0x" << hex << cur_pc;
     }
 
     if (inst->isMicroop()) {
-        outs << "." << setw(2) << dec << upc;
+        outs << "." << setw(2) << dec << pc.microPC();
     } else {
         outs << "   ";
     }
@@ -87,27 +104,37 @@ Trace::ExeTracerRecord::traceInst(StaticInstPtr inst, bool ran)
     //
 
     outs << setw(26) << left;
-    outs << inst->disassemble(PC, debugSymbolTable);
+    outs << inst->disassemble(cur_pc, debugSymbolTable);
 
     if (ran) {
         outs << " : ";
 
-        if (IsOn(ExecOpClass)) {
+        if (Debug::ExecOpClass) {
             outs << Enums::OpClassStrings[inst->opClass()] << " : ";
         }
 
-        if (IsOn(ExecResult) && data_status != DataInvalid) {
+        if (Debug::ExecResult && !predicate) {
+            outs << "Predicated False";
+        }
+
+        if (Debug::ExecResult && data_status != DataInvalid) {
             ccprintf(outs, " D=%#018x", data.as_int);
         }
 
-        if (IsOn(ExecEffAddr) && addr_valid)
+        if (Debug::ExecEffAddr && getMemValid())
             outs << " A=0x" << hex << addr;
 
-        if (IsOn(ExecFetchSeq) && fetch_seq_valid)
+        if (Debug::ExecFetchSeq && fetch_seq_valid)
             outs << "  FetchSeq=" << dec << fetch_seq;
 
-        if (IsOn(ExecCPSeq) && cp_seq_valid)
+        if (Debug::ExecCPSeq && cp_seq_valid)
             outs << "  CPSeq=" << dec << cp_seq;
+
+        if (Debug::ExecFlags) {
+            outs << "  flags=(";
+            inst->printFlags(outs, "|");
+            outs << ")";
+        }
     }
 
     //
@@ -127,19 +154,19 @@ Trace::ExeTracerRecord::dump()
      * finishes. Macroops then behave like regular instructions and don't
      * complete/print when they fault.
      */
-    if (IsOn(ExecMacro) && staticInst->isMicroop() &&
-            (IsOn(ExecMicro) &&
-             macroStaticInst && staticInst->isFirstMicroop()) ||
-            (!IsOn(ExecMicro) &&
-             macroStaticInst && staticInst->isLastMicroop())) {
+    if (Debug::ExecMacro && staticInst->isMicroop() &&
+        ((Debug::ExecMicro &&
+            macroStaticInst && staticInst->isFirstMicroop()) ||
+            (!Debug::ExecMicro &&
+             macroStaticInst && staticInst->isLastMicroop()))) {
         traceInst(macroStaticInst, false);
     }
-    if (IsOn(ExecMicro) || !staticInst->isMicroop()) {
+    if (Debug::ExecMicro || !staticInst->isMicroop()) {
         traceInst(staticInst, true);
     }
 }
 
-/* namespace Trace */ }
+} // namespace Trace
 
 ////////////////////////////////////////////////////////////////////////
 //
@@ -149,4 +176,4 @@ Trace::ExeTracer *
 ExeTracerParams::create()
 {
     return new Trace::ExeTracer(this);
-};
+}