Hoa Nguyen has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/38359 )

Change subject: python: Improve SimObject's warning when parent specified twice
......................................................................

python: Improve SimObject's warning when parent specified twice

SimObject outputs a warning when its parent is specified more than
once. The cause is most likely that there is unexpected param
specified in the constructor called in the Python interface.

This commit adds a note about this probable cause of this potential
error to the warning message.

Change-Id: I9b6bf5d5fb0c77bfdad5fde42e88f814e8a4b72b
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
---
M src/python/m5/SimObject.py
1 file changed, 3 insertions(+), 2 deletions(-)



diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index f8d6c27..b47d98d 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1484,8 +1484,9 @@
     def add_child(self, name, child):
         child = coerceSimObjectOrVector(child)
         if child.has_parent():
-            warn("add_child('%s'): child '%s' already has parent", name,
-                child.get_name())
+ warn(f"{self}.{name} already has parent (Previously declared as "
+                 f"{child._parent}.{name}).\n"
+ f"\tNote: {name} is not a parameter of {type(self).__name__}")
         if name in self._children:
# This code path had an undiscovered bug that would make it fail
             # at runtime. It had been here for a long time and was only

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/38359
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: I9b6bf5d5fb0c77bfdad5fde42e88f814e8a4b72b
Gerrit-Change-Number: 38359
Gerrit-PatchSet: 1
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
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

Reply via email to