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

Cleanup/optimize break_next_call: compile regex once #1803

Closed
disconnect3d opened this issue Jul 18, 2023 · 0 comments
Closed

Cleanup/optimize break_next_call: compile regex once #1803

disconnect3d opened this issue Jul 18, 2023 · 0 comments
Labels
Milestone

Comments

@disconnect3d
Copy link
Member

The break_next_call function which steps through the execution has this functionality that it can stop on a target symbol checked via a regular expression.

However, both the regular expression as well as the string provided to it are constructed on each loop iteration (!). While Python regexes are cached internally, we should not rely on this functionality.

# return call if we match target address
if ins.target_const and re.match(f"{symbol_regex}$", hex(ins.target)):
return ins
# return call if we match symbol name
if ins.symbol and re.match(f"{symbol_regex}$", ins.symbol):
return ins

Effectively, this issue is just about doing something like:

symbol_re = re.compile(f"{symbol_regex}$")

while ...:
    if ... and symbol_re.match(...): ...
@disconnect3d disconnect3d added this to the 2023.10 milestone Jul 18, 2023
disconnect3d added a commit that referenced this issue Jul 18, 2023
This commit changes `break_next_call` so it compiles the symbol regex
once, but also it changes the regex so that we do not append `$` at the
end of it.

The appending of `$` was counter-intuitive imho and it was never said to
the user that this happens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant