diff --git a/src/arch/arm/tracers/SConscript b/src/arch/arm/tracers/SConscript index a509b220ed..15945a4ac4 100644 --- a/src/arch/arm/tracers/SConscript +++ b/src/arch/arm/tracers/SConscript @@ -36,7 +36,7 @@ Import('*') SimObject('TarmacTrace.py', sim_objects=['TarmacParser', 'TarmacTracer'], - tags='arm isa') + enums=['TarmacDump'], tags='arm isa') Source('tarmac_base.cc', tags='arm isa') Source('tarmac_parser.cc', tags='arm isa') Source('tarmac_tracer.cc', tags='arm isa') diff --git a/src/arch/arm/tracers/TarmacTrace.py b/src/arch/arm/tracers/TarmacTrace.py index 0e87ec995b..82c447aada 100644 --- a/src/arch/arm/tracers/TarmacTrace.py +++ b/src/arch/arm/tracers/TarmacTrace.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 ARM Limited +# Copyright (c) 2018, 2022 Arm Limited # All rights reserved. # # The license below extends only to copyright in the software and shall @@ -67,6 +67,10 @@ class TarmacParser(InstTracer): ) +class TarmacDump(ScopedEnum): + vals = ["stdoutput", "stderror", "file"] + + class TarmacTracer(InstTracer): type = "TarmacTracer" cxx_class = "gem5::trace::TarmacTracer" @@ -79,3 +83,13 @@ class TarmacTracer(InstTracer): end_tick = Param.Tick( MaxTick, "tracing ends when the tick time gets this value" ) + outfile = Param.TarmacDump( + "stdoutput", + "Selects where the tracer is dumping its output" + "Current options are:" + "1) stdoutput = dump to standard output" + "2) stderror = dump to standard error" + "3) file = dump to a file. As there is one tracer per CPU," + "this means every CPU will dump its trace to a different file," + "name after the tracer name (e.g. cpu0.tracer, cpu1.tracer)", + ) diff --git a/src/arch/arm/tracers/tarmac_record.cc b/src/arch/arm/tracers/tarmac_record.cc index 9d56aa39ee..59d6a18b39 100644 --- a/src/arch/arm/tracers/tarmac_record.cc +++ b/src/arch/arm/tracers/tarmac_record.cc @@ -374,7 +374,7 @@ template void TarmacTracerRecord::flushQueues(Queue& queue) { - std::ostream &outs = trace::output(); + std::ostream &outs = tracer.output(); for (const auto &single_entry : queue) { single_entry->print(outs); diff --git a/src/arch/arm/tracers/tarmac_tracer.cc b/src/arch/arm/tracers/tarmac_tracer.cc index 15f6abcc47..aa454f7539 100644 --- a/src/arch/arm/tracers/tarmac_tracer.cc +++ b/src/arch/arm/tracers/tarmac_tracer.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited + * Copyright (c) 2017-2018, 2022 Arm Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -40,8 +40,11 @@ #include #include "arch/arm/system.hh" +#include "base/output.hh" #include "cpu/base.hh" +#include "enums/TarmacDump.hh" + namespace gem5 { @@ -54,8 +57,28 @@ TarmacContext::tarmacCpuName() const return "cpu" + std::to_string(id); } +namespace { + +OutputStream * +tarmacDump(const TarmacTracerParams &p) +{ + switch (p.outfile) { + case TarmacDump::stdoutput: + return simout.findOrCreate("stdout"); + case TarmacDump::stderror: + return simout.findOrCreate("stderr"); + case TarmacDump::file: + return simout.findOrCreate(p.name); + default: + panic("Invalid option\n"); + } +} + +} + TarmacTracer::TarmacTracer(const Params &p) : InstTracer(p), + outstream(tarmacDump(p)), startTick(p.start_tick), endTick(p.end_tick) { @@ -95,5 +118,11 @@ TarmacTracer::getInstRecord(Tick when, ThreadContext *tc, } } +std::ostream& +TarmacTracer::output() +{ + return *(outstream->stream()); +} + } // namespace trace } // namespace gem5 diff --git a/src/arch/arm/tracers/tarmac_tracer.hh b/src/arch/arm/tracers/tarmac_tracer.hh index 7e7b409543..f8c7b5ca53 100644 --- a/src/arch/arm/tracers/tarmac_tracer.hh +++ b/src/arch/arm/tracers/tarmac_tracer.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited + * Copyright (c) 2017-2018, 2022 Arm Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -54,6 +54,7 @@ namespace gem5 { class ThreadContext; +class OutputStream; namespace trace { @@ -104,12 +105,16 @@ class TarmacTracer : public InstTracer const StaticInstPtr staticInst, const PCStateBase &pc, const StaticInstPtr macroStaticInst=nullptr) override; + std::ostream& output(); + protected: typedef std::unique_ptr PEntryPtr; typedef TarmacTracerRecord::InstPtr InstPtr; typedef TarmacTracerRecord::MemPtr MemPtr; typedef TarmacTracerRecord::RegPtr RegPtr; + OutputStream *outstream; + /** * startTick and endTick allow to trace a specific window of ticks * rather than the entire CPU execution.