Hoa Nguyen has submitted this change. ( 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 <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38359
Maintainer: Bobby R. Bruce <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/python/m5/SimObject.py
1 file changed, 3 insertions(+), 2 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



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: 2
Gerrit-Owner: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to