# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
 # Copyright (c) 2009 The Hewlett-Packard Development Company
+# Copyright (c) 2013 Advanced Micro Devices, Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
             # handled differently. Hence the check whether or not
             # the str_list is empty.
 
+            dflag = "%s" % (self.exprs[0].name)
+            machine.addDebugFlag(dflag)
             format = "%s" % (self.exprs[1].inline())
             format_length = len(format)
             str_list = []
                 str_list.append("%s" % self.exprs[i].inline())
 
             if len(str_list) == 0:
-                code('DPRINTF(RubySlicc, "$0: $1")',
-                     self.exprs[0].location, format[2:format_length-2])
+                code('DPRINTF($0, "$1: $2")',
+                     dflag, self.exprs[0].location, format[2:format_length-2])
             else:
-                code('DPRINTF(RubySlicc, "$0: $1", $2)',
+                code('DPRINTF($0, "$1: $2", $3)',
+                     dflag,
                      self.exprs[0].location, format[2:format_length-2],
                      ', '.join(str_list))
 
 
 # Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
 # Copyright (c) 2009 The Hewlett-Packard Development Company
+# Copyright (c) 2013 Advanced Micro Devices, Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
         self.objects = []
         self.TBEType   = None
         self.EntryType = None
+        self.debug_flags = set()
+        self.debug_flags.add('RubyGenerated')
+        self.debug_flags.add('RubySlicc')
 
     def __repr__(self):
         return "[StateMachine: %s]" % self.ident
 
         self.actions[action.ident] = action
 
+    def addDebugFlag(self, flag):
+        self.debug_flags.add(flag)
+
     def addRequestType(self, request_type):
         assert self.table is None
         self.request_types[request_type.ident] = request_type
 #include "mem/ruby/common/Consumer.hh"
 #include "mem/ruby/slicc_interface/AbstractController.hh"
 #include "params/$c_ident.hh"
+
 ''')
 
         seen_types = set()
  */
 
 #include <sys/types.h>
-#include <typeinfo>
 #include <unistd.h>
 
 #include <cassert>
 #include <sstream>
 #include <string>
+#include <typeinfo>
 
 #include "base/compiler.hh"
 #include "base/cprintf.hh"
-#include "debug/RubyGenerated.hh"
-#include "debug/RubySlicc.hh"
+
+''')
+        for f in self.debug_flags:
+            code('#include "debug/${{f}}.hh"')
+        code('''
 #include "mem/protocol/${ident}_Controller.hh"
 #include "mem/protocol/${ident}_Event.hh"
 #include "mem/protocol/${ident}_State.hh"
 #include "mem/protocol/Types.hh"
 #include "mem/ruby/system/System.hh"
+
 ''')
         for include_path in includes:
             code('#include "${{include_path}}"')
 // ${ident}: ${{self.short}}
 
 #include <sys/types.h>
-#include <typeinfo>
 #include <unistd.h>
 
 #include <cassert>
+#include <typeinfo>
 
 #include "base/misc.hh"
-#include "debug/RubySlicc.hh"
+
+''')
+        for f in self.debug_flags:
+            code('#include "debug/${{f}}.hh"')
+        code('''
 #include "mem/protocol/${ident}_Controller.hh"
 #include "mem/protocol/${ident}_Event.hh"
 #include "mem/protocol/${ident}_State.hh"
+
 ''')
 
         if outputRequest_types:
         code('''
 #include "mem/protocol/Types.hh"
 #include "mem/ruby/system/System.hh"
+
 ''')