Giacomo Travaglini has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/44967 )
Change subject: base: Add DPRINTFV macro
......................................................................
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 <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44967
Tested-by: kokoro <[email protected]>
Reviewed-by: Daniel Carvalho <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
---
M src/base/trace.hh
1 file changed, 16 insertions(+), 1 deletion(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
Daniel Carvalho: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/base/trace.hh b/src/base/trace.hh
index 36fcee4..be8476b 100644
--- a/src/base/trace.hh
+++ b/src/base/trace.hh
@@ -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 @@
* 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 @@
} \
} 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 @@
#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)
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44967
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I793cf1521303fd0a3bbea2059a9447386f83661e
Gerrit-Change-Number: 44967
Gerrit-PatchSet: 4
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s