Making Lookback a subclass of Breakpoint allows using it by itself to generate a state trace on halts

This commit is contained in:
Neil Webber 2023-10-03 15:53:57 -05:00
parent ac3ed72d34
commit e2fbf38786

View file

@ -101,9 +101,11 @@ class NthBreakpoint:
# FOR EXAMPLE:
# class StepsPlusLookback(Lookback, StepsBreakpoint)
# pass
class Lookback:
#
# ALTERNATIVELY, can be used entirely by itself, and will provide
# a lookback if the run() loop terminates for any reason (e.g., a HALT).
#
class Lookback(Breakpoint):
def __init__(self, *args, lookbacks=100, **kwargs):
self.__backstates = collections.deque([], lookbacks)
@ -118,6 +120,7 @@ class Lookback:
return list(self.__backstates)
class MultiBreakpoint(Breakpoint):
# a breakpoint that fires if any of the contained breakpoints fire