sim: Add some helpers to catch and reporting using unbound ports.
authorGabe Black <gabeblack@google.com>
Sat, 13 Jun 2020 04:28:12 +0000 (21:28 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 16 Jun 2020 02:35:41 +0000 (02:35 +0000)
commitd3024accaf29b4a35bf7d1a0a0beeda05787100c
treeb8e116516a0d0052bcff4d47a5c0d30ad8cd84a5
parent5d80780f89ae91dc1632265fa2a6b0ffcab6dfa6
sim: Add some helpers to catch and reporting using unbound ports.

If a port is unbound, trying to call its peer will likely cause a
segfault. Rather than check if a port is bound every time you go to use
it, we can instead bind to a default peer which just throws an exception
back to the caller. The caller can catch the exception and report the
error.

This change adds a common new class to throw as the exception, and also
a small utility function which reports the error and dies.

Change-Id: Ia58a2030922c73e2fd7d139822bce38d9b0f2171
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/30295
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/sim/port.cc
src/sim/port.hh