From e2fbf3878645d27b66c878474b57a1fe18060457 Mon Sep 17 00:00:00 2001 From: Neil Webber Date: Tue, 3 Oct 2023 15:53:57 -0500 Subject: [PATCH] Making Lookback a subclass of Breakpoint allows using it by itself to generate a state trace on halts --- breakpoints.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/breakpoints.py b/breakpoints.py index 9d370c7..76f3a39 100644 --- a/breakpoints.py +++ b/breakpoints.py @@ -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