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

Refactor mutation_replace_binary_operator to use macros #205

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

JamesLee-Jones
Copy link
Collaborator

No description provided.

@JamesLee-Jones JamesLee-Jones marked this pull request as draft November 22, 2023 16:33
@JamesLee-Jones
Copy link
Collaborator Author

@afd There are two approaches I could take with this PR. I could either replace the mutation of each operator with their own macro, i.e

#define REPLACE_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1^=arg2
#define REPLACE_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1-=arg2
#define REPLACE_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1-arg2
#define REPLACE_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1>>=arg2
#define REPLACE_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1<<=arg2

or we instead extract the template and have one macro MUTATE(mutation_id_offset, arg) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg.

The former approach would allow different mutation templates to be applied to different operators if desired, but the later would simplify the output code substantially. What is your opinion?

@JamesLee-Jones
Copy link
Collaborator Author

The first approach is implemented at the moment, but could be changed quite easily.

@JamesLee-Jones JamesLee-Jones marked this pull request as ready for review November 22, 2023 17:20
@afd
Copy link
Member

afd commented Nov 22, 2023

I'm not sure. I think the approach with more macros, allowing more flexibility per macro, is probably better. I don't anticipate the current approach to mutation with Dredd changing much, so I guess we need to think through what your use case for coverage-guided fuzzing will need. For your use case I can see us needing quite a bit of flexibility, as each operator will need different UB checking. So it's likely the first approach you mention is better.

Note: this macros approach is just one thing we should consider. It could be that we go some way down that road and decide it's not what we want after all, but it's hard to know until we try, so thanks for initially prototyping this.

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.

2 participants