mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-29 18:00:18 +00:00
m1n1.trace: Add a state
stash to Tracer that persists
This allows Tracers to keep internal state around even across complete re-instantiations. Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
7090138779
commit
9e42f4fc0f
1 changed files with 16 additions and 3 deletions
|
@ -44,6 +44,9 @@ class RegCache(Reloadable):
|
|||
else:
|
||||
raise Exception("Cannot write register in asynchronous context")
|
||||
|
||||
class TracerState:
|
||||
pass
|
||||
|
||||
class Tracer(Reloadable):
|
||||
DEFAULT_MODE = TraceMode.ASYNC
|
||||
|
||||
|
@ -53,10 +56,20 @@ class Tracer(Reloadable):
|
|||
self.ident = type(self).__name__
|
||||
self.regmaps = {}
|
||||
self.verbose = verbose
|
||||
self.state = TracerState()
|
||||
self.init_state()
|
||||
self._cache = RegCache(hv)
|
||||
if self.ident in hv.tracer_caches:
|
||||
self._cache.cache = dict(hv.tracer_caches[self.ident])
|
||||
hv.tracer_caches[self.ident] = self._cache.cache
|
||||
cache = hv.tracer_caches.get(self.ident, None)
|
||||
if cache is not None:
|
||||
self._cache.cache.update(cache.get("regcache", {}))
|
||||
self.state.__dict__.update(cache.get("state", {}))
|
||||
hv.tracer_caches[self.ident] = {
|
||||
"regcache": self._cache.cache,
|
||||
"state": self.state.__dict__
|
||||
}
|
||||
|
||||
def init_state(self):
|
||||
pass
|
||||
|
||||
def evt_rw(self, evt, regmap=None, prefix=None):
|
||||
self._cache.update(evt.addr, evt.data)
|
||||
|
|
Loading…
Reference in a new issue