Giacomo Travaglini has uploaded this change for review. ( 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 variable as a first
argument, 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]>
---
M src/base/trace.hh
1 file changed, 10 insertions(+), 1 deletion(-)



diff --git a/src/base/trace.hh b/src/base/trace.hh
index 86dec09..36cb707 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
@@ -199,6 +199,14 @@
     }                                                  \
 } while (0)

+#define DPRINTFV(x, ...) do {                          \
+    using namespace Debug;                             \
+    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)
@@ -218,6 +226,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)

--
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: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to