|
|
|
|
@ -6,6 +6,7 @@ new library/objfile are loaded, etc.
|
|
|
|
|
|
|
|
|
|
import functools
|
|
|
|
|
import sys
|
|
|
|
|
import typing as t
|
|
|
|
|
from collections.abc import Hashable
|
|
|
|
|
from typing import Any
|
|
|
|
|
from typing import Callable
|
|
|
|
|
@ -14,6 +15,17 @@ from typing import List # noqa: F401
|
|
|
|
|
|
|
|
|
|
debug = False
|
|
|
|
|
|
|
|
|
|
# https://stackoverflow.com/a/75013308/803801
|
|
|
|
|
if t.TYPE_CHECKING:
|
|
|
|
|
F = t.TypeVar("F")
|
|
|
|
|
reset_on_stop: Callable[[F], F]
|
|
|
|
|
reset_on_prompt: Callable[[F], F]
|
|
|
|
|
reset_on_exit: Callable[[F], F]
|
|
|
|
|
reset_on_objfile: Callable[[F], F]
|
|
|
|
|
reset_on_start: Callable[[F], F]
|
|
|
|
|
reset_on_cont: Callable[[F], F]
|
|
|
|
|
reset_on_thread: Callable[[F], F]
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
class memoize:
|
|
|
|
|
"""
|
|
|
|
|
@ -65,7 +77,6 @@ class memoize:
|
|
|
|
|
print("Clearing %s %r" % (self, self.cache))
|
|
|
|
|
self.cache.clear()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class forever(memoize):
|
|
|
|
|
"""
|
|
|
|
|
Memoizes forever - for a pwndbg session or until `_reset` is called explicitly.
|
|
|
|
|
@ -79,7 +90,6 @@ class forever(memoize):
|
|
|
|
|
for obj in forever.caches:
|
|
|
|
|
obj.cache.clear()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class reset_on_stop(memoize):
|
|
|
|
|
caches = [] # type: List[reset_on_stop]
|
|
|
|
|
kind = "stop"
|
|
|
|
|
@ -91,7 +101,6 @@ class reset_on_stop(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_on_stop
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class reset_on_prompt(memoize):
|
|
|
|
|
caches = [] # type: List[reset_on_prompt]
|
|
|
|
|
kind = "prompt"
|
|
|
|
|
@ -103,7 +112,6 @@ class reset_on_prompt(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_on_prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class reset_on_exit(memoize):
|
|
|
|
|
caches = [] # type: List[reset_on_exit]
|
|
|
|
|
kind = "exit"
|
|
|
|
|
@ -115,7 +123,6 @@ class reset_on_exit(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_on_exit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class reset_on_objfile(memoize):
|
|
|
|
|
caches = [] # type: List[reset_on_objfile]
|
|
|
|
|
kind = "objfile"
|
|
|
|
|
@ -127,7 +134,6 @@ class reset_on_objfile(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_on_objfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class reset_on_start(memoize):
|
|
|
|
|
caches = [] # type: List[reset_on_start]
|
|
|
|
|
kind = "start"
|
|
|
|
|
@ -139,7 +145,6 @@ class reset_on_start(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_on_start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class reset_on_cont(memoize):
|
|
|
|
|
caches = [] # type: List[reset_on_cont]
|
|
|
|
|
kind = "cont"
|
|
|
|
|
@ -151,7 +156,6 @@ class reset_on_cont(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_on_cont
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class reset_on_thread(memoize):
|
|
|
|
|
caches = [] # type: List[reset_on_thread]
|
|
|
|
|
kind = "thread"
|
|
|
|
|
@ -163,7 +167,6 @@ class reset_on_thread(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_on_thread
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class while_running(memoize):
|
|
|
|
|
caches = [] # type: List[while_running]
|
|
|
|
|
kind = "running"
|
|
|
|
|
@ -181,7 +184,6 @@ class while_running(memoize):
|
|
|
|
|
|
|
|
|
|
_reset = __reset_while_running
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reset() -> None:
|
|
|
|
|
forever._reset()
|
|
|
|
|
reset_on_stop._reset()
|
|
|
|
|
|