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

[Question] rr-debugger as a library? #3632

Open
4kreed opened this issue Oct 20, 2023 · 6 comments
Open

[Question] rr-debugger as a library? #3632

4kreed opened this issue Oct 20, 2023 · 6 comments

Comments

@4kreed
Copy link

4kreed commented Oct 20, 2023

Would it be possible to use rr-debugger as a library? I have a use case where I want to record the execution of all my tests and only keep the record if the test failed (and do that programatically).

I'm wondering if it is possible to call RecordCommand::run() before executing my test. Maybe this doesn't make sense but I can see a real advantage of being able to at least record by using some APIs from a library.

Thanks for your time.

@rocallahan
Copy link
Collaborator

I have a use case where I want to record the execution of all my tests and only keep the record if the test failed (and do that programatically).

rr returns the exit code of the application you recorded. So you can write a program (e.g. a shell script) that runs rr, checks the exit code, and delete the recording if the test failed.

@4kreed
Copy link
Author

4kreed commented Oct 23, 2023

Thanks for your quick response!

Right, I was wondering about a more fine grained execution, so let's say I have a tester that runs 100 tests. I'd like to record each test individually and keep the record only if the test failed (and not the recording of the execution of the entire tester).

Also, and specially, in a fuzz testing scenario, where the same code is tested multiple times based on the generated inputs by the fuzz engine (a process that can't be stopped and relaunched, since metrics like coverage would be loss), I'd like to record the execution of the code for each generated input, and again discard the recording based on the result.

Is there any mechanism that could fit for this scenario?

Again, thanks for your time, any help is much appreciated.

@rocallahan
Copy link
Collaborator

rr can't split up a recording of a single process execution to just isolate one sub-test that failed.

For fuzzing, usually people take the failing fuzzing input, run some minimization algorithm on it, and then re-record that with rr for debugging.

@4kreed
Copy link
Author

4kreed commented Nov 14, 2023

Thanks again for your response and sorry for the delay in mine.

I apologize if I haven't expressed myself clearly, it is not about splitting up a recording but making recordings in a more fine tune way. The idea would be to be able to start and stop recordings by calling some public API (let's say, recordStart() and recordStop()) from the source code and thus using rr as a library.

Nevertheless, I understand from your messages that this scenario/functionality is not currently provided by rr. Based on your knowledge about the tool, do you think this is something achievable? I'm thinking about implementing this functionality myself but I'm not even sure if it is possible at all. Any comment or hint about it would be greatly appreciated.

Again, thanks for your time, I appreciate a lot your help.

@4kreed
Copy link
Author

4kreed commented Dec 14, 2023

@rocallahan Did you have the chance to see my latest comment? Any thoughts about it?

Greatly appreciated :)

@rocallahan
Copy link
Collaborator

The idea would be to be able to start and stop recordings by calling some public API (let's say, recordStart() and recordStop()) from the source code and thus using rr as a library.

It probably could be done but it would be pretty hard. The especially hard part is taking a snapshot of the current state at the start of the recording and getting everything set up. Right now we rely on setting everything (e.g. seccomp filters) up in an initial process and then all other tracees inheriting the right settings, and also on setting up various things whenever there's an execve.

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

No branches or pull requests

2 participants