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

repl: flush log to output #172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

repl: flush log to output #172

wants to merge 1 commit into from

Conversation

ChiChou
Copy link
Contributor

@ChiChou ChiChou commented Oct 24, 2024

frida repl sometimes generates empty log file when using --output flag.

Here is the minimal case to reproduce:

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    CFRunLoopRun();
    return 0;
}
  • Compile with cc main.m -o test -fmodules
  • frida -f ./test -e "console.log('foo')" -o log

Log file will be empty.


Here is also an alternative way to fix:

- self._logfile = codecs.open(options.logfile, "w", "utf-8")
+ self._logfile = codecs.open(options.logfile, "w", "utf-8", buffering=0)

Since tracer.py is calling flush() explicitly, to keep the style consistent, this patch remains the same

class OutputFile:
def __init__(self, filename: str) -> None:
self._fd = codecs.open(filename, "wb", "utf-8")
def close(self) -> None:
self._fd.close()
def append(self, message: str) -> None:
self._fd.write(message)
self._fd.flush()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant