Ciro Santilli has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/22004 )

Change subject: base: add the --debug-flag to DPRINTF output
......................................................................

base: add the --debug-flag to DPRINTF output

This makes it easier to determine which messages come from which
flags when enabling multiple flags at once.

This commit covers the bulk of the debug messages, which use the DPRINTF*
family of macros. There however macros that use DTRACE to check for
enable, those will be covered in future patches.

Change-Id: I6738b18f08ccfd1e11f2874b426c1827b42e82a2
---
M src/base/trace.cc
M src/base/trace.hh
M util/systemc/gem5_within_systemc/sc_logger.cc
M util/systemc/gem5_within_systemc/sc_logger.hh
4 files changed, 58 insertions(+), 44 deletions(-)



diff --git a/src/base/trace.cc b/src/base/trace.cc
index 06f9eeb..9db5180 100644
--- a/src/base/trace.cc
+++ b/src/base/trace.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 ARM Limited
+ * Copyright (c) 2014, 2019 ARM Limited
  * All rights reserved
  *
  * Copyright (c) 2001-2006 The Regents of The University of Michigan
@@ -101,8 +101,10 @@

 ObjectMatch ignore;

+
 void
-Logger::dump(Tick when, const std::string &name, const void *d, int len)
+Logger::dump(Tick when, const std::string &name,
+         const void *d, int len, const std::string &flag)
 {
     if (!name.empty() && ignore.match(name))
         return;
@@ -133,7 +135,7 @@
         }

         ccprintf(line, "\n");
-        logMessage(when, name, line.str());
+        logMessage(when, name, flag, line.str());

         if (c < 16)
             break;
@@ -142,7 +144,7 @@

 void
 OstreamLogger::logMessage(Tick when, const std::string &name,
-                          const std::string &message)
+        const std::string &flag, const std::string &message)
 {
     if (!name.empty() && ignore.match(name))
         return;
@@ -150,6 +152,9 @@
     if (when != MaxTick)
         ccprintf(stream, "%7d: ", when);

+    if (!flag.empty())
+        stream << flag << ": ";
+
     if (!name.empty())
         stream << name << ": ";

diff --git a/src/base/trace.hh b/src/base/trace.hh
index ee87372..1e77415 100644
--- a/src/base/trace.hh
+++ b/src/base/trace.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 ARM Limited
+ * Copyright (c) 2014, 2019 ARM Limited
  * All rights reserved
  *
  * Copyright (c) 2001-2006 The Regents of The University of Michigan
@@ -60,21 +60,29 @@
     void dprintf(Tick when, const std::string &name, const char *fmt,
                  const Args &...args)
     {
+        dprintf_flag(when, name, "", fmt, args...);
+    }
+
+    /** Log a single message with a flag prefix. */
+    template <typename ...Args>
+    void dprintf_flag(Tick when, const std::string &name,
+            const std::string &flag,
+            const char *fmt, const Args &...args)
+    {
         if (!name.empty() && ignore.match(name))
             return;
-
         std::ostringstream line;
         ccprintf(line, fmt, args...);
-        logMessage(when, name, line.str());
+        logMessage(when, name, flag, line.str());
     }

     /** Dump a block of data of length len */
-    virtual void dump(Tick when, const std::string &name,
-                      const void *d, int len);
+    void dump(Tick when, const std::string &name,
+            const void *d, int len, const std::string &flag);

     /** Log formatted message */
     virtual void logMessage(Tick when, const std::string &name,
-                            const std::string &message) = 0;
+            const std::string &flag, const std::string &message) = 0;

     /** Return an ostream that can be used to send messages to
      *  the 'same place' as formatted logMessage messages.  This
@@ -104,7 +112,7 @@
     { }

     void logMessage(Tick when, const std::string &name,
-                    const std::string &message) override;
+            const std::string &flag, const std::string &message) override;

     std::ostream &getOstream() override { return stream; }
 };
@@ -166,46 +174,47 @@

 #define DTRACE(x) (Debug::x)

-#define DDUMP(x, data, count) do {                                        \
-    using namespace Debug;                                                \
-    if (DTRACE(x))                                                        \
-        Trace::getDebugLogger()->dump(curTick(), name(), data, count);    \
+#define DDUMP(x, data, count) do {               \
+    using namespace Debug;                       \
+    if (DTRACE(x))                               \
+        Trace::getDebugLogger()->dump(           \
+            curTick(), name(), data, count, #x); \
 } while (0)

-#define DPRINTF(x, ...) do {                                              \
-    using namespace Debug;                                                \
-    if (DTRACE(x)) {                                                      \
-        Trace::getDebugLogger()->dprintf(curTick(), name(),               \
-            __VA_ARGS__);                                                 \
-    }                                                                     \
+#define DPRINTF(x, ...) do {                     \
+    using namespace Debug;                       \
+    if (DTRACE(x)) {                             \
+        Trace::getDebugLogger()->dprintf_flag(   \
+            curTick(), name(), #x, __VA_ARGS__); \
+    }                                            \
 } while (0)

-#define DPRINTFS(x, s, ...) do {                                          \
-    using namespace Debug;                                                \
-    if (DTRACE(x)) {                                                      \
-        Trace::getDebugLogger()->dprintf(curTick(), s->name(),            \
-            __VA_ARGS__);                                                 \
-    }                                                                     \
+#define DPRINTFS(x, s, ...) do {                        \
+    using namespace Debug;                              \
+    if (DTRACE(x)) {                                    \
+        Trace::getDebugLogger()->dprintf_flag(          \
+                curTick(), s->name(), #x, __VA_ARGS__); \
+    }                                                   \
 } while (0)

-#define DPRINTFR(x, ...) do {                                             \
-    using namespace Debug;                                                \
-    if (DTRACE(x)) {                                                      \
-        Trace::getDebugLogger()->dprintf((Tick)-1, std::string(),         \
-            __VA_ARGS__);                                                 \
-    }                                                                     \
+#define DPRINTFR(x, ...) do {                          \
+    using namespace Debug;                             \
+    if (DTRACE(x)) {                                   \
+        Trace::getDebugLogger()->dprintf_flag(         \
+            (Tick)-1, std::string(), #x, __VA_ARGS__); \
+    }                                                  \
 } while (0)

-#define DDUMPN(data, count) do {                                          \
-    Trace::getDebugLogger()->dump(curTick(), name(), data, count);        \
+#define DDUMPN(data, count) do {                                       \
+    Trace::getDebugLogger()->dump(curTick(), name(), data, count);     \
 } while (0)

-#define DPRINTFN(...) do {                                                \
-    Trace::getDebugLogger()->dprintf(curTick(), name(), __VA_ARGS__);     \
+#define DPRINTFN(...) do {                                             \
+    Trace::getDebugLogger()->dprintf(curTick(), name(), __VA_ARGS__);  \
 } while (0)

-#define DPRINTFNR(...) do {                                               \
-    Trace::getDebugLogger()->dprintf((Tick)-1, string(), __VA_ARGS__);    \
+#define DPRINTFNR(...) do {                                            \
+    Trace::getDebugLogger()->dprintf((Tick)-1, string(), __VA_ARGS__); \
 } while (0)

 #else // !TRACING_ON
diff --git a/util/systemc/gem5_within_systemc/sc_logger.cc b/util/systemc/gem5_within_systemc/sc_logger.cc
index a8b9020..195a0cb 100644
--- a/util/systemc/gem5_within_systemc/sc_logger.cc
+++ b/util/systemc/gem5_within_systemc/sc_logger.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 ARM Limited
+ * Copyright (c) 2014, 2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -79,7 +79,7 @@

 void CuttingStreambuf::outputLine()
 {
-    logger->logMessage((Tick)-1, "gem5", line.str());
+    logger->logMessage((Tick)-1, "gem5", "", line.str());
     line.clear();
     line.str("");
 }
@@ -133,7 +133,7 @@
 /** Log a single message as a single sc_report call */
 void
 Logger::logMessage(Tick when, const std::string &name,
-    const std::string &message)
+    const std::string &flag, const std::string &message)
 {
     /* Need to chop the newline off the message */
     std::string message_without_nl = message;
diff --git a/util/systemc/gem5_within_systemc/sc_logger.hh b/util/systemc/gem5_within_systemc/sc_logger.hh
index 4143f8b..0f9c6a1 100644
--- a/util/systemc/gem5_within_systemc/sc_logger.hh
+++ b/util/systemc/gem5_within_systemc/sc_logger.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 ARM Limited
+ * Copyright (c) 2014, 2019 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -70,7 +70,7 @@

     /** Log a single message as a single sc_report call */
     void logMessage(Tick when, const std::string &name,
-        const std::string &message);
+            const std::string &flag, const std::string &message) override;

     std::ostream &getOstream();
 };

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/22004
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I6738b18f08ccfd1e11f2874b426c1827b42e82a2
Gerrit-Change-Number: 22004
Gerrit-PatchSet: 1
Gerrit-Owner: Ciro Santilli <ciro.santi...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to