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

add trash block generator #825

Merged
merged 2 commits into from
Jan 16, 2024
Merged

add trash block generator #825

merged 2 commits into from
Jan 16, 2024

Conversation

pagran
Copy link
Member

@pagran pagran commented Jan 2, 2024

Controversial point - a separate test file for trash generator. I did it for simplifying coverage estimation (now 92.5%), what I think is important because a lot of variations of trash code can be generated by algorithm.

Docs for users in next pullrequest

For making static code analysis even more difficult, added feature for
generating trash blocks that will never be executed. In combination
with control flow flattening makes it hard to separate trash code from
the real one, plus it causes a large number of trash references to
different methods.

Trash blocks contain 2 types of statements:
1. Function/method call with writing the results into local variables
and passing them to other calls
2. Shuffling or assigning random values to local variables
@pagran
Copy link
Member Author

pagran commented Jan 2, 2024

Trash code example (1024 stmts): https://go.godbolt.org/z/1WE9MT898 (from 52 line)

@pagran pagran requested review from mvdan and lu4p January 7, 2024 15:10
internal/ctrlflow/ctrlflow.go Outdated Show resolved Hide resolved
internal/ctrlflow/transform.go Show resolved Hide resolved
internal/ctrlflow/transform.go Show resolved Hide resolved
internal/ctrlflow/trash.go Outdated Show resolved Hide resolved
internal/ctrlflow/trash.go Outdated Show resolved Hide resolved
internal/ctrlflow/trash.go Outdated Show resolved Hide resolved
internal/ctrlflow/trash.go Outdated Show resolved Hide resolved
internal/ctrlflow/trash.go Show resolved Hide resolved
internal/ctrlflow/trash_test.go Show resolved Hide resolved
@pagran pagran requested a review from lu4p January 15, 2024 07:50
@pagran pagran merged commit e8fe80d into burrowers:master Jan 16, 2024
5 checks passed
@mvdan
Copy link
Member

mvdan commented Feb 7, 2024

Docs for users in next pullrequest

@pagran did you mean to send this PR? I'm looking at doing another release, but I think this new trash block generator isn't documented yet.

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

Successfully merging this pull request may close these issues.

3 participants