Skip to content

Commit

Permalink
hasattr->getattr for better pretender compat
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusmue committed Jan 22, 2020
1 parent f5caa51 commit 9908413
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions avatar2/protocols/coresight.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_vtor(self):
return self._origin.read_memory(SCB_VTOR, 4)

def get_ivt_addr(self):
if hasattr(self._origin, 'ivt_address'):
if getattr(self._origin, 'ivt_address', None) is not None:
return self._origin.ivt_address
else:
return self.get_vtor()
Expand Down Expand Up @@ -283,11 +283,11 @@ def inject_monitor_stub(self, addr=0x20001234, vtor=0x20002000):
self._monitor_stub_writeme = addr + 8
# Pivot VTOR, if needed
# On CM0, you can't, so don't.
if not hasattr(self._origin, 'ivt_address'):
if getattr(self._origin, 'ivt_address', None) is None:
if self.get_vtor() == 0:
self.set_vtor(vtor)
# Sometimes, we need to gain access to the IVT (make it writable). Do that here.
if hasattr(self._origin, 'ivt_unlock'):
if getattr(self._origin, 'ivt_unlock', None) is not None:
unlock_addr, unlock_val = self._origin.ivt_unlock
self._origin.write_memory(unlock_addr, 4, unlock_val)
# put the stub
Expand Down

0 comments on commit 9908413

Please sign in to comment.