[gem5-dev] [M] Change in gem5/gem5[develop]: arch-arm: Allow TarmacTracer to dump trace to a file
Giacomo Travaglini has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/63892?usp=email ) Change subject: arch-arm: Allow TarmacTracer to dump trace to a file .. arch-arm: Allow TarmacTracer to dump trace to a file This patch is adding an outfile parameter to the TarmacTracer This has 3 options: 1) stdoutput = dump to standard output (default behaviour) 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, named after the tracer name (e.g. cpu0.tracer, cpu1.tracer) It is still possible to redirect to a file with option 1 and 2 thanks to common bash redirection. What the third option is really buying us is the capability to dump CPU traces on separate files, and to separate the trace output from the debug-flag output Change-Id: Icd2bcc721f8598d494c9efabdf5e092666ebdece Signed-off-by: Giacomo Travaglini Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63892 Maintainer: Andreas Sandberg Reviewed-by: Richard Cooper Tested-by: kokoro Reviewed-by: Andreas Sandberg --- M src/arch/arm/tracers/SConscript M src/arch/arm/tracers/TarmacTrace.py M src/arch/arm/tracers/tarmac_record.cc M src/arch/arm/tracers/tarmac_tracer.cc M src/arch/arm/tracers/tarmac_tracer.hh 5 files changed, 83 insertions(+), 5 deletions(-) Approvals: Richard Cooper: Looks good to me, approved Andreas Sandberg: Looks good to me, approved; Looks good to me, approved kokoro: Regressions pass diff --git a/src/arch/arm/tracers/SConscript b/src/arch/arm/tracers/SConscript index a509b22..15945a4 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 0e87ec9..82c447a 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 TarmacDump(ScopedEnum): +vals = ["stdoutput", "stderror", "file"] + + class TarmacTracer(InstTracer): type = "TarmacTracer" cxx_class = "gem5::trace::TarmacTracer" @@ -79,3 +83,13 @@ 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 9d56aa3..59d6a18 100644 --- a/src/arch/arm/tracers/tarmac_record.cc +++ b/src/arch/arm/tracers/tarmac_record.cc @@ -374,7 +374,7 @@ void TarmacTracerRecord::flushQueues(Queue& queue) { -std::ostream = trace::output(); +std::ostream = tracer.output(); for (const auto _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 15f6abc..aa454f7 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 @@ return "cpu" + std::to_string(id); } +namespace { + +OutputStream * +tarmacDump(const TarmacTracerParams ) +{ +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 ) : InstTracer(p), +outstream(tarmacDump(p)), startTick(p.start_tick), endTick(p.end_tick) { @@ -95,5 +118,11 @@ } } +std::ostream&
[gem5-dev] [M] Change in gem5/gem5[develop]: arch-arm: Allow TarmacTracer to dump trace to a file
Giacomo Travaglini has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/63892?usp=email ) Change subject: arch-arm: Allow TarmacTracer to dump trace to a file .. arch-arm: Allow TarmacTracer to dump trace to a file This patch is adding an outfile parameter to the TarmacTracer This has 3 options: 1) stdoutput = dump to standard output (default behaviour) 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, named after the tracer name (e.g. cpu0.tracer, cpu1.tracer) It is still possible to redirect to a file with option 1 and 2 thanks to common bash redirection. What the third option is really buying us is the capability to dump CPU traces on separate files Change-Id: Icd2bcc721f8598d494c9efabdf5e092666ebdece Signed-off-by: Giacomo Travaglini --- M src/arch/arm/tracers/SConscript M src/arch/arm/tracers/TarmacTrace.py M src/arch/arm/tracers/tarmac_tracer.cc M src/arch/arm/tracers/tarmac_tracer.hh 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/arch/arm/tracers/SConscript b/src/arch/arm/tracers/SConscript index a509b22..15945a4 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 0e87ec9..82c447a 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 TarmacDump(ScopedEnum): +vals = ["stdoutput", "stderror", "file"] + + class TarmacTracer(InstTracer): type = "TarmacTracer" cxx_class = "gem5::trace::TarmacTracer" @@ -79,3 +83,13 @@ 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_tracer.cc b/src/arch/arm/tracers/tarmac_tracer.cc index 15f6abc..aa454f7 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 @@ return "cpu" + std::to_string(id); } +namespace { + +OutputStream * +tarmacDump(const TarmacTracerParams ) +{ +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 ) : InstTracer(p), +outstream(tarmacDump(p)), startTick(p.start_tick), endTick(p.end_tick) { @@ -95,5 +118,11 @@ } } +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 7e7b409..f8c7b5c 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 @@ { class ThreadContext; +class OutputStream; namespace trace { @@ -104,12 +105,16 @@ const StaticInstPtr staticInst, const PCStateBase , const StaticInstPtr macroStaticInst=nullptr) override; +std::ostream& output(); + protected: typedef std::unique_ptr PEntryPtr; typedef