Jason Lowe-Power has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/51787 )
Change subject: python: Updates to improve debugging output
......................................................................
python: Updates to improve debugging output
This changeset updates SimObject and Proxy so that certain errors are
easier to diagnose. In SimObject, the warn() statement could cause
another exception, so it's split into two statements. In Proxy, it is
helpful to know which attribute is referenced when there's a mistake.
Change-Id: I3704a247b8b40e18ffc5e4a6241a74829313c07e
Signed-off-by: Jason Lowe-Power <[email protected]>
---
M src/python/m5/proxy.py
M src/python/m5/SimObject.py
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index 923700d..4dfa2d7 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1525,9 +1525,9 @@
def add_child(self, name, child):
child = coerceSimObjectOrVector(child)
if child.has_parent():
- warn(f"{self}.{name} already has parent (Previously declared
as "
- f"{child._parent}.{name}), not resetting parent.\n"
+ warn(f"{self}.{name} already has parent not resetting
parent.\n"
f"\tNote: {name} is not a parameter of
{type(self).__name__}")
+ warn(f"(Previously declared as {child._parent}.{name}")
return
if name in self._children:
# This code path had an undiscovered bug that would make it
fail
diff --git a/src/python/m5/proxy.py b/src/python/m5/proxy.py
index fe4cb65..2de0ee7 100644
--- a/src/python/m5/proxy.py
+++ b/src/python/m5/proxy.py
@@ -172,7 +172,8 @@
if attr.startswith('_'):
return super(AttrProxy, self).__getattr__(self, attr)
if hasattr(self, '_pdesc'):
- raise AttributeError("Attribute reference on bound proxy")
+ raise AttributeError("Attribute reference on bound proxy "
+ f"({self}.{attr})")
# Return a copy of self rather than modifying self in place
# since self could be an indirect reference via a variable or
# parameter
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/51787
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: I3704a247b8b40e18ffc5e4a6241a74829313c07e
Gerrit-Change-Number: 51787
Gerrit-PatchSet: 1
Gerrit-Owner: Jason Lowe-Power <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s