mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
Kernel/KCOV: Bring closer to typical SerenityOS coding style
- Remove a bunch of redundant `this->` - Make class data members private and provide accessors instead
This commit is contained in:
parent
79fbad6df9
commit
91fe6b6552
4 changed files with 44 additions and 39 deletions
|
@ -12,7 +12,6 @@ namespace Kernel {
|
|||
KCOVInstance::KCOVInstance(ProcessID pid)
|
||||
{
|
||||
m_pid = pid;
|
||||
state = UNUSED;
|
||||
}
|
||||
|
||||
KResult KCOVInstance::buffer_allocate(size_t buffer_size_in_entries)
|
||||
|
@ -21,27 +20,27 @@ KResult KCOVInstance::buffer_allocate(size_t buffer_size_in_entries)
|
|||
return EINVAL;
|
||||
|
||||
// first entry contains index of last PC
|
||||
this->m_buffer_size_in_entries = buffer_size_in_entries - 1;
|
||||
this->m_buffer_size_in_bytes = Memory::page_round_up(buffer_size_in_entries * KCOV_ENTRY_SIZE);
|
||||
m_buffer_size_in_entries = buffer_size_in_entries - 1;
|
||||
m_buffer_size_in_bytes = Memory::page_round_up(buffer_size_in_entries * KCOV_ENTRY_SIZE);
|
||||
|
||||
// one single vmobject is representing the buffer
|
||||
// - we allocate one kernel region using that vmobject
|
||||
// - when an mmap call comes in, we allocate another userspace region,
|
||||
// backed by the same vmobject
|
||||
auto maybe_vmobject = Memory::AnonymousVMObject::try_create_with_size(
|
||||
this->m_buffer_size_in_bytes, AllocationStrategy::AllocateNow);
|
||||
m_buffer_size_in_bytes, AllocationStrategy::AllocateNow);
|
||||
if (maybe_vmobject.is_error())
|
||||
return maybe_vmobject.error();
|
||||
this->vmobject = maybe_vmobject.release_value();
|
||||
m_vmobject = maybe_vmobject.release_value();
|
||||
|
||||
this->m_kernel_region = MM.allocate_kernel_region_with_vmobject(
|
||||
*this->vmobject, this->m_buffer_size_in_bytes, String::formatted("kcov_{}", this->m_pid),
|
||||
m_kernel_region = MM.allocate_kernel_region_with_vmobject(
|
||||
*m_vmobject, m_buffer_size_in_bytes, String::formatted("kcov_{}", m_pid),
|
||||
Memory::Region::Access::ReadWrite);
|
||||
if (!this->m_kernel_region)
|
||||
if (!m_kernel_region)
|
||||
return ENOMEM;
|
||||
|
||||
this->m_buffer = (u64*)this->m_kernel_region->vaddr().as_ptr();
|
||||
if (!this->has_buffer())
|
||||
m_buffer = (u64*)m_kernel_region->vaddr().as_ptr();
|
||||
if (!has_buffer())
|
||||
return ENOMEM;
|
||||
|
||||
return KSuccess;
|
||||
|
@ -49,14 +48,14 @@ KResult KCOVInstance::buffer_allocate(size_t buffer_size_in_entries)
|
|||
|
||||
void KCOVInstance::buffer_add_pc(u64 pc)
|
||||
{
|
||||
auto idx = (u64)this->m_buffer[0];
|
||||
if (idx >= this->m_buffer_size_in_entries) {
|
||||
auto idx = (u64)m_buffer[0];
|
||||
if (idx >= m_buffer_size_in_entries) {
|
||||
// the buffer is already full
|
||||
return;
|
||||
}
|
||||
|
||||
this->m_buffer[idx + 1] = pc;
|
||||
this->m_buffer[0] = idx + 1;
|
||||
m_buffer[idx + 1] = pc;
|
||||
m_buffer[0] = idx + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue