Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Our Breakpoint class should reset all stop caches #1805

Closed
disconnect3d opened this issue Jul 18, 2023 · 0 comments · Fixed by #1806
Closed

Our Breakpoint class should reset all stop caches #1805

disconnect3d opened this issue Jul 18, 2023 · 0 comments · Fixed by #1806
Labels
bug enhancement For enhancements to existing features good first issue help wanted

Comments

@disconnect3d
Copy link
Member

Essentially what I wrote here #1799 (comment) - instead of clearing only registers cache, we should clear all caches that were registered to be cleared by the 'stop' event in our Breakpoint class:

class Breakpoint(gdb.Breakpoint):
"""
Breakpoint class, similar to gdb.Breakpoint, but clears the caches
associated with the stop event before determining whether it should stop the
inferior or not.
Unlike gdb.Breakpoint, users of this class should override `should_stop()`,
instead of `stop()`, as the latter is used to do cache invalidation.
"""
def stop(self):
# Clear the cache for the stop event.
pwndbg.gdblib.regs.__getattr__.cache.clear()
return self.should_stop()
def should_stop(self):
"""
This function is called whenever this breakpoint is hit in the code and
its return value determines whether the inferior will be stopped.
"""
return True

This can be done with this code:

pwndbg.lib.cache._ALL_CACHE_UNTIL_EVENTS['stop'].clear()

but we should probably make a function for this instead of using the _... variable? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement For enhancements to existing features good first issue help wanted
Development

Successfully merging a pull request may close this issue.

1 participant