base: Add DPRINTFV macro
This macro is directly expecting a Debug::Flag instance as a first
argument instead of simply the name of the debug flag, and it is
forwarding it with no preprocessing to the underlying logic
(dprintf_flag).
This is different from the common DPRINTF, which is converting the
first argument into a flag and into a string literal.
This is useful if we want to pass the DebugFlag from the subclass to
the superclass. This makes it possible to set tracepoints in the
Base class logic, and let the Derived classes define the flag which
will enable the tracepoint
class Base
{
Base(const Debug::SimpleFlag &_flag)
: flag(_flag) {}
void baseLogic()
{
DPRINTFV(flag, "...");
}
const Debug::SimpleFlag flag;
}
class Derived1 : public Base
{
Derived1() : Base(Debug::Derived1) {}
}
class Derived2 : public Base
{
Derived2() : Base(Debug::Derived2) {}
}
A more concrete example is Arm Table Walker, which is using a DmaPort.
If we want to log the table walker port activity, we are using the
--debug-flags=DMA, which is unconvenient as it will contain the
logs from every DMA device in the simulation
Change-Id: I793cf1521303fd0a3bbea2059a9447386f83661e
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44967
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2019 ARM Limited
|
||||
* Copyright (c) 2014, 2019, 2021 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* Copyright (c) 2001-2006 The Regents of The University of Michigan
|
||||
@@ -154,10 +154,17 @@ const std::string &name();
|
||||
* If you desire that the automatic printing not occur, use DPRINTFR
|
||||
* (R for raw)
|
||||
*
|
||||
* With DPRINTFV it is possible to pass a Debug::SimpleFlag variable
|
||||
* as first argument. Example:
|
||||
*
|
||||
* Debug::Flag some_flag = Debug::DMA;
|
||||
* DPRINTFV(some_flag, ...);
|
||||
*
|
||||
* \def DDUMP(x, data, count)
|
||||
* \def DPRINTF(x, ...)
|
||||
* \def DPRINTFS(x, s, ...)
|
||||
* \def DPRINTFR(x, ...)
|
||||
* \def DPRINTFV(x, ...)
|
||||
* \def DPRINTFN(...)
|
||||
* \def DPRINTFNR(...)
|
||||
* \def DPRINTF_UNCONDITIONAL(x, ...)
|
||||
@@ -195,6 +202,13 @@ const std::string &name();
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTFV(x, ...) do { \
|
||||
if (M5_UNLIKELY(x)) { \
|
||||
Trace::getDebugLogger()->dprintf_flag( \
|
||||
curTick(), name(), x.name(), __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DPRINTFN(...) do { \
|
||||
Trace::getDebugLogger()->dprintf(curTick(), name(), __VA_ARGS__); \
|
||||
} while (0)
|
||||
@@ -214,6 +228,7 @@ const std::string &name();
|
||||
#define DPRINTF(x, ...) do {} while (0)
|
||||
#define DPRINTFS(x, ...) do {} while (0)
|
||||
#define DPRINTFR(...) do {} while (0)
|
||||
#define DPRINTFV(...) do {} while (0)
|
||||
#define DPRINTFN(...) do {} while (0)
|
||||
#define DPRINTFNR(...) do {} while (0)
|
||||
#define DPRINTF_UNCONDITIONAL(x, ...) do {} while (0)
|
||||
|
||||
Reference in New Issue
Block a user