sim: fail on implicit creation of orphans via ports
authorSteve Reinhardt <steve.reinhardt@amd.com>
Tue, 17 Aug 2010 12:06:22 +0000 (05:06 -0700)
committerSteve Reinhardt <steve.reinhardt@amd.com>
Tue, 17 Aug 2010 12:06:22 +0000 (05:06 -0700)
Orphan SimObjects (not in the config hierarchy) could get
created implicitly if they have a port connection to a SimObject
that is in the hierarchy.  This means that there are objects on
the C++ SimObject list (created via the C++ SimObject
constructor call) that are unknown to Python and will get
skipped if we walk the hierarchy from the Python side (as we are
about to do).  This patch detects this situation and prints an
error message.

Also fix the rubytester config script which happened to rely on
this behavior.

src/python/m5/SimObject.py
src/python/m5/params.py
tests/configs/rubytest-ruby.py

index 8e14b63d29bb1ac3a0f5149c5ca6c3de16f338ad..69f79ed615a63847897cd6d3665d0b532544e5ec 100644 (file)
@@ -761,13 +761,16 @@ class SimObject(object):
     # children.
     def getCCObject(self):
         if not self._ccObject:
-            # Cycles in the configuration heirarchy are not supported. This
+            # Make sure this object is in the configuration hierarchy
+            if not self._parent and not isRoot(self):
+                raise RuntimeError, "Attempt to instantiate orphan node"
+            # Cycles in the configuration hierarchy are not supported. This
             # will catch the resulting recursion and stop.
             self._ccObject = -1
             params = self.getCCParams()
             self._ccObject = params.create()
         elif self._ccObject == -1:
-            raise RuntimeError, "%s: Cycle found in configuration heirarchy." \
+            raise RuntimeError, "%s: Cycle found in configuration hierarchy." \
                   % self.path()
         return self._ccObject
 
@@ -890,6 +893,10 @@ def isSimObjectSequence(value):
 def isSimObjectOrSequence(value):
     return isSimObject(value) or isSimObjectSequence(value)
 
+def isRoot(obj):
+    from m5.objects import Root
+    return obj and obj is Root.getInstance()
+
 baseClasses = allClasses.copy()
 baseInstances = instanceDict.copy()
 
index cf64070c55878766c60cb96ffc7e0d147c191e9b..d9578e15730d5e506a40cea8f0192a3acfa8d5cc 100644 (file)
@@ -1049,8 +1049,14 @@ class PortRef(object):
         peer = self.peer
         if not self.peer: # nothing to connect to
             return
-        connectPorts(self.simobj.getCCObject(), self.name, self.index,
-                     peer.simobj.getCCObject(), peer.name, peer.index)
+        try:
+            connectPorts(self.simobj.getCCObject(), self.name, self.index,
+                         peer.simobj.getCCObject(), peer.name, peer.index)
+        except:
+            print "Error connecting port %s.%s to %s.%s" % \
+                  (self.simobj.path(), self.name,
+                   peer.simobj.path(), peer.name)
+            raise
         self.ccConnected = True
         peer.ccConnected = True
 
index 5bdfe39ddf24ead7c000c21710f9cda9fe0087cd..ad217a140b22a3b7e4e344ee5a88dedca0e4a979 100644 (file)
@@ -70,7 +70,7 @@ execfile(os.path.join(config_root, "configs/common", "Options.py"))
 #
 tester = RubyTester(checks_to_complete = 100, wakeup_frequency = 10)
 
-system = System(physmem = PhysicalMemory())
+system = System(tester = tester, physmem = PhysicalMemory())
 
 system.ruby = Ruby.create_system(options, system.physmem)