diff options
| author | Alexander Potapenko <glider@google.com> | 2025-08-01 12:12:42 +0200 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2025-08-05 13:16:45 +0000 |
| commit | 77ff614fa0319f7b4e99df29822d0590128bf00c (patch) | |
| tree | 8103f61472890a7b8f9eaf417b3f185fa0d1c537 /executor/executor_darwin.h | |
| parent | 0931f9bfa8eacf9840a2bd3f9def3cfb4349431e (diff) | |
executor: decouple kcov memory allocation from the trace
On different platforms and in different coverage collection modes
the pointer to the beginning of kcov buffer may or may not differ
from the pointer to the region that mmap() returned.
Decouple these two pointers, so that the memory is always allocated
and deallocated with cov->mmap_alloc_ptr and cov->mmap_alloc_size, and the
buffer is accessed via cov->data and cov->data_size.
I tried my best to not break Darwin and BSD, but I did not test them.
Diffstat (limited to 'executor/executor_darwin.h')
| -rw-r--r-- | executor/executor_darwin.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/executor/executor_darwin.h b/executor/executor_darwin.h index bb7956c20..d555eeb02 100644 --- a/executor/executor_darwin.h +++ b/executor/executor_darwin.h @@ -73,7 +73,7 @@ static void cover_open(cover_t* cov, bool extra) static void cover_mmap(cover_t* cov) { - if (cov->data != NULL) + if (cov->mmap_alloc_ptr != NULL) fail("cover_mmap invoked on an already mmapped cover_t object"); uintptr_t mmap_ptr = 0; if (ksancov_map(cov->fd, &mmap_ptr, &cov->mmap_alloc_size)) @@ -84,6 +84,7 @@ static void cover_mmap(cover_t* cov) if (cov->mmap_alloc_size > kCoverSize) fail("mmap allocation size larger than anticipated"); + cov->mmap_alloc_ptr = (char*)mmap_ptr; cov->data = (char*)mmap_ptr; cov->data_end = cov->data + cov->mmap_alloc_size; } |
