#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;
namespace Trace {
void
-Trace::ExeTracerRecord::dump()
+ExeTracerRecord::dumpTicks(ostream &outs)
+{
+ ccprintf(outs, "%7d: ", when);
+}
+
+void
+Trace::ExeTracerRecord::traceInst(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))
+ if (Debug::ExecSpeculative)
outs << (misspeculating ? "-" : "+") << " ";
- if (IsOn(ExecThread))
- outs << "T" << thread->threadId() << " : ";
+ if (Debug::ExecAsid)
+ outs << "A" << dec << TheISA::getExecutingAsid(thread) << " ";
+ 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);
- outs << "@" << sym_str << " : ";
+ Addr cur_pc = pc.instAddr();
+ if (debugSymbolTable && Debug::ExecSymbol && !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 << cur_pc;
}
- else {
- outs << "0x" << hex << PC << " : ";
+
+ if (inst->isMicroop()) {
+ outs << "." << setw(2) << dec << pc.microPC();
+ } else {
+ outs << " ";
}
+ outs << " : ";
+
//
// Print decoded instruction
//
outs << setw(26) << left;
- outs << staticInst->disassemble(PC, debugSymbolTable);
- outs << " : ";
+ outs << inst->disassemble(cur_pc, debugSymbolTable);
- if (IsOn(ExecOpClass)) {
- outs << Enums::OpClassStrings[staticInst->opClass()] << " : ";
- }
+ if (ran) {
+ outs << " : ";
- if (IsOn(ExecResult) && data_status != DataInvalid) {
- ccprintf(outs, " D=%#018x", data.as_int);
- }
+ if (Debug::ExecOpClass) {
+ outs << Enums::OpClassStrings[inst->opClass()] << " : ";
+ }
- if (IsOn(ExecEffAddr) && addr_valid)
- outs << " A=0x" << hex << addr;
+ if (Debug::ExecResult && predicate == false) {
+ outs << "Predicated False";
+ }
- if (IsOn(ExecFetchSeq) && fetch_seq_valid)
- outs << " FetchSeq=" << dec << fetch_seq;
+ if (Debug::ExecResult && data_status != DataInvalid) {
+ ccprintf(outs, " D=%#018x", data.as_int);
+ }
- if (IsOn(ExecCPSeq) && cp_seq_valid)
- outs << " CPSeq=" << dec << cp_seq;
+ if (Debug::ExecEffAddr && addr_valid)
+ outs << " A=0x" << hex << addr;
+
+ if (Debug::ExecFetchSeq && fetch_seq_valid)
+ outs << " FetchSeq=" << dec << fetch_seq;
+
+ if (Debug::ExecCPSeq && cp_seq_valid)
+ outs << " CPSeq=" << dec << cp_seq;
+ }
//
// End of line...
outs << endl;
}
-/* namespace Trace */ }
+void
+Trace::ExeTracerRecord::dump()
+{
+ /*
+ * The behavior this check tries to achieve is that if ExecMacro is on,
+ * the macroop will be printed. If it's on and microops are also on, it's
+ * printed before the microops start printing to give context. If the
+ * microops aren't printed, then it's printed only when the final microop
+ * finishes. Macroops then behave like regular instructions and don't
+ * complete/print when they fault.
+ */
+ if (Debug::ExecMacro && staticInst->isMicroop() &&
+ ((Debug::ExecMicro &&
+ macroStaticInst && staticInst->isFirstMicroop()) ||
+ (!Debug::ExecMicro &&
+ macroStaticInst && staticInst->isLastMicroop()))) {
+ traceInst(macroStaticInst, false);
+ }
+ if (Debug::ExecMicro || !staticInst->isMicroop()) {
+ traceInst(staticInst, true);
+ }
+}
+
+} // namespace Trace
////////////////////////////////////////////////////////////////////////
//
ExeTracerParams::create()
{
return new Trace::ExeTracer(this);
-};
+}