[gem5-dev] Change in gem5/gem5[develop]: scons: Separate debug flags from debug-format flags

2021-02-02 Thread Daniel Carvalho (Gerrit) via gem5-dev
Daniel Carvalho has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/39076 )


Change subject: scons: Separate debug flags from debug-format flags
..

scons: Separate debug flags from debug-format flags

Debug flags are flags that aid with debugging by printing
relevant information when enabled. Debug-formatting flags
define how the debug flags will print the information.

Although a viability, this patch does not support declaring
compound format flags.

As a side effect, now debug flags and debug-formatting flags
are printed in different lists, when using --debug-help.

Change-Id: Ieae68745276218cf4e9c1d37d7bf3bd1f19709ae
Signed-off-by: Daniel R. Carvalho 
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39076
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
Tested-by: kokoro 
---
M src/SConscript
M src/base/SConscript
M src/base/debug.hh
M src/base/debug.test.cc
M src/python/m5/debug.py
M src/python/pybind11/debug.cc
6 files changed, 54 insertions(+), 15 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/SConscript b/src/SConscript
index dc57260..6637b1f 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -618,20 +618,24 @@
 # Debug Flags
 #
 debug_flags = {}
-def DebugFlag(name, desc=None):
+def DebugFlag(name, desc=None, fmt=False):
 if name in debug_flags:
 raise AttributeError("Flag {} already specified".format(name))
-debug_flags[name] = (name, (), desc)
+debug_flags[name] = (name, (), desc, fmt)

 def CompoundFlag(name, flags, desc=None):
 if name in debug_flags:
 raise AttributeError("Flag {} already specified".format(name))

 compound = tuple(flags)
-debug_flags[name] = (name, compound, desc)
+debug_flags[name] = (name, compound, desc, False)
+
+def DebugFormatFlag(name, desc=None):
+DebugFlag(name, desc, True)

 Export('DebugFlag')
 Export('CompoundFlag')
+Export('DebugFormatFlag')

 
 #
@@ -1109,11 +1113,14 @@
 ''')

 for name, flag in sorted(source[0].read().items()):
-n, compound, desc = flag
+n, compound, desc, fmt = flag
 assert n == name

 if not compound:
-code('SimpleFlag $name("$name", "$desc");')
+if fmt:
+code('SimpleFlag $name("$name", "$desc", true);')
+else:
+code('SimpleFlag $name("$name", "$desc", false);')
 else:
 comp_code('CompoundFlag $name("$name", "$desc", {')
 comp_code.indent()
@@ -1132,7 +1139,7 @@
 assert(len(target) == 1 and len(source) == 1)

 val = eval(source[0].get_contents())
-name, compound, desc = val
+name, compound, desc, fmt = val

 code = code_formatter()

@@ -1168,7 +1175,7 @@
 code.write(str(target[0]))

 for name,flag in sorted(debug_flags.items()):
-n, compound, desc = flag
+n, compound, desc, fmt = flag
 assert n == name

 hh_file = 'debug/%s.hh' % name
diff --git a/src/base/SConscript b/src/base/SConscript
index 204ed3c..ff32166 100644
--- a/src/base/SConscript
+++ b/src/base/SConscript
@@ -102,10 +102,6 @@
 DebugFlag('Annotate', "State machine annotation debugging")
 DebugFlag('AnnotateQ', "State machine annotation queue debugging")
 DebugFlag('AnnotateVerbose', "Dump all state machine annotation details")
-DebugFlag('FmtFlag', "Show the --debug-flag that enabled each debug  
message")

-DebugFlag('FmtStackTrace',
-"Print a stack trace after every debug message")
-DebugFlag('FmtTicksOff', "Don't show tick count on debug messages")
 DebugFlag('GDBAcc', "Remote debugger accesses")
 DebugFlag('GDBExtra', "Dump extra information on reads and writes")
 DebugFlag('GDBMisc', "Breakpoints, traps, watchpoints, etc.")
@@ -124,3 +120,8 @@
 CompoundFlag('AnnotateAll', ['Annotate', 'AnnotateQ', 'AnnotateVerbose'],
 desc="All Annotation flags")

+DebugFormatFlag('FmtFlag',
+"Show the --debug-flag that enabled each debug message")
+DebugFormatFlag('FmtStackTrace',
+"Print a stack trace after every debug message")
+DebugFormatFlag('FmtTicksOff', "Don't show tick count on debug messages")
diff --git a/src/base/debug.hh b/src/base/debug.hh
index 2d46381..be5fa36 100644
--- a/src/base/debug.hh
+++ b/src/base/debug.hh
@@ -81,18 +81,31 @@
 class SimpleFlag : public Flag
 {
   protected:
+/** Whether this flag changes debug formatting. */
+const bool _isFormat = false;
+
 bool _tracing = false; // tracing is enabled and flag is on
 bool _enabled = false; // flag enablement status

 void sync() override { _tracing = _globalEnable && _enabled; }

   public:
-SimpleFlag(const char *name, const char *desc) : Flag(name, desc) {}
+SimpleFlag(const char *name, const char *desc, bool is_format=false)
+  : Flag(name, desc),

[gem5-dev] Change in gem5/gem5[develop]: scons: Separate debug flags from debug-format flags

2021-01-13 Thread Daniel Carvalho (Gerrit) via gem5-dev
Daniel Carvalho has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/39076 )



Change subject: scons: Separate debug flags from debug-format flags
..

scons: Separate debug flags from debug-format flags

Debug flags are flags that aid with debugging by printing
relevant information when enabled. Debug-formatting flags
define how the debug flags will print the information.

Although a viability, this patch does not support declaring
compound format flags.

Finally, as of this patch, the C++ debug flag code is still
unaware of this difference.

Change-Id: Ieae68745276218cf4e9c1d37d7bf3bd1f19709ae
Signed-off-by: Daniel R. Carvalho 
---
M src/SConscript
M src/base/SConscript
2 files changed, 15 insertions(+), 10 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index b55f485..2533810 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -623,20 +623,24 @@
 # Debug Flags
 #
 debug_flags = {}
-def DebugFlag(name, desc=None):
+def DebugFlag(name, desc=None, fmt=False):
 if name in debug_flags:
 raise AttributeError("Flag {} already specified".format(name))
-debug_flags[name] = (name, (), desc)
+debug_flags[name] = (name, (), desc, fmt)

 def CompoundFlag(name, flags, desc=None):
 if name in debug_flags:
 raise AttributeError("Flag {} already specified".format(name))

 compound = tuple(flags)
-debug_flags[name] = (name, compound, desc)
+debug_flags[name] = (name, compound, desc, False)
+
+def DebugFormatFlag(name, desc=None):
+DebugFlag(name, desc, True)

 Export('DebugFlag')
 Export('CompoundFlag')
+Export('DebugFormatFlag')

 
 #
@@ -1114,7 +1118,7 @@
 ''')

 for name, flag in sorted(source[0].read().items()):
-n, compound, desc = flag
+n, compound, desc, fmt = flag
 assert n == name

 if not compound:
@@ -1137,7 +1141,7 @@
 assert(len(target) == 1 and len(source) == 1)

 val = eval(source[0].get_contents())
-name, compound, desc = val
+name, compound, desc, fmt = val

 code = code_formatter()

@@ -1173,7 +1177,7 @@
 code.write(str(target[0]))

 for name,flag in sorted(debug_flags.items()):
-n, compound, desc = flag
+n, compound, desc, fmt = flag
 assert n == name

 hh_file = 'debug/%s.hh' % name
diff --git a/src/base/SConscript b/src/base/SConscript
index 3ac9838..5b5e578 100644
--- a/src/base/SConscript
+++ b/src/base/SConscript
@@ -99,10 +99,6 @@
 DebugFlag('Annotate', "State machine annotation debugging")
 DebugFlag('AnnotateQ', "State machine annotation queue debugging")
 DebugFlag('AnnotateVerbose', "Dump all state machine annotation details")
-DebugFlag('FmtFlag', "Show the --debug-flag that enabled each debug  
message")

-DebugFlag('FmtStackTrace',
-"Print a stack trace after every debug message")
-DebugFlag('FmtTicksOff', "Don't show tick count on debug messages")
 DebugFlag('GDBAcc', "Remote debugger accesses")
 DebugFlag('GDBExtra', "Dump extra information on reads and writes")
 DebugFlag('GDBMisc', "Breakpoints, traps, watchpoints, etc.")
@@ -121,3 +117,8 @@
 CompoundFlag('AnnotateAll', ['Annotate', 'AnnotateQ', 'AnnotateVerbose'],
 desc="All Annotation flags")

+DebugFormatFlag('FmtFlag',
+"Show the --debug-flag that enabled each debug message")
+DebugFormatFlag('FmtStackTrace',
+"Print a stack trace after every debug message")
+DebugFormatFlag('FmtTicksOff', "Don't show tick count on debug messages")

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39076
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: Ieae68745276218cf4e9c1d37d7bf3bd1f19709ae
Gerrit-Change-Number: 39076
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s