From 350278b84d51bc4ec5c2ed7aa1bcdd22d3670078 Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Mon, 7 Dec 2020 17:45:18 -0800 Subject: [PATCH] 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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38359 Maintainer: Bobby R. Bruce Reviewed-by: Jason Lowe-Power Tested-by: kokoro --- src/python/m5/SimObject.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index f8d6c27e6..b47d98d83 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -1484,8 +1484,9 @@ class SimObject(object): 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 -- 2.30.2