Skip to content

executor: refactor struct cover_t #5809

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

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

Conversation

ramosian-glider
Copy link
Member

Instead of having a single void *data pointer that is used to both allocate the memory and access the trace, split it into:

  • void *alloc of size mmap_alloc_size, used by mmap/munmap to manage the memory for kcov (may contain other data apart from the trace)
  • void *trace of size trace_size, used to access the collected trace

Future patches will introduce other collection modes that may relocate the trace, so *alloc and *trace won't be interchangeable anymore.

I tried my best to not break Darwin and BSD, but I didn't test them.


Before sending a pull request, please review Contribution Guidelines:
https://github.com/google/syzkaller/blob/master/docs/contributing.md


Instead of having a single `void *data` pointer that is used to both
allocate the memory and access the trace, split it into:
 - `void *alloc` of size `mmap_alloc_size`, used by mmap/munmap to manage
   the memory for kcov (may contain other data apart from the trace)
 - `void *trace` of size `trace_size`, used to access the collected trace

Future patches will introduce other collection modes that may relocate
the trace, so `alloc` and `trace` won't be interchangeable anymore.

Also rename `trace_offset` to `trace_skip`. From now on, `XXX_offset`
is the offset of `XXX` from the beginning of `alloc`, and `trace_skip`
is the number of bytes to skip from the beginning of the trace to get to
the actual PCs.

I tried my best to not break Darwin and BSD, but I didn't test them.
@a-nogikh
Copy link
Collaborator

FTR: there might happen some conflict between the changes from this PR and #5799

@ramosian-glider
Copy link
Member Author

FTR: there might happen some conflict between the changes from this PR and #5799

Thanks for the heads-up! I will incorporate their changes once they land.

Copy link
Collaborator

@dvyukov dvyukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me.

void* alloc;
// Buffer used by kcov for collecting PCs.
char* trace;
uint32 trace_size;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep only trace_end.

cov->data_offset = is_kernel_64_bit ? sizeof(uint64_t) : sizeof(uint32_t);
cov->trace_offset = 0;
cov->trace = (char*)cov->alloc;
// TODO(glider): trace size and may be different from mmap_alloc_size in the future.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look useful as TODO in the code.

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.

3 participants