python: Prevent Python wrappers from deleting SimObjects
authorAndreas Sandberg <andreas.sandberg@arm.com>
Tue, 9 May 2017 18:28:47 +0000 (19:28 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Mon, 22 May 2017 17:15:09 +0000 (17:15 +0000)
commitca1d18d599dcc620bf526fb22042af95b1b60b68
treefc4833267ec2f50bec469f6ef6bd665403d1aeb0
parent2da0ab06b720e5b22fb3a81585ef9eecc752a99f
python: Prevent Python wrappers from deleting SimObjects

The PyBind wrappers could potentially delete SimObjects if they don't
have any references. This is not desirable since there could be
pointers to such objects within the C++ world. This problem doesn't
normally occur since Python typically holds a pointer to the root node
as long as the simulator is running.

Prevent SimObject and Param deletion by using a PyBind-prescribed
unique_ptr with a dummy deleter as the pointer wrapper for the Python
world.

Change-Id: Ied14602c9ee69a083a69c5dae1b5fcf8efb4548a
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/3224
Reviewed-by: Gabe Black <gabeblack@google.com>
src/python/m5/SimObject.py
src/python/pybind11/core.cc