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 <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63892 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Richard Cooper <richard.cooper@arm.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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)",
|
||||
)
|
||||
|
||||
@@ -374,7 +374,7 @@ template<typename Queue>
|
||||
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);
|
||||
|
||||
@@ -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 <string>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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<Printable> 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.
|
||||
|
||||
Reference in New Issue
Block a user