serenity/Kernel/Devices/KCOVDevice.h
Space Meyer a721e4d507 Kernel: Track KCOVInstance via Process instead of HashMap
While this clutters Process.cpp a tiny bit, I feel that it's worth it:
- 2x speed on the kcov_loop benchmark. Likely more during fuzzing.
- Overall code complexity is going down with this change.
- By reducing the code reachable from __sanitizer_cov_trace_pc code,
  we can now instrument more code.
2024-04-15 21:16:22 -06:00

39 lines
1.4 KiB
C++

/*
* Copyright (c) 2021, Patrick Meyer <git@the-space.agency>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/Devices/KCOVInstance.h>
namespace Kernel {
class KCOVDevice final : public BlockDevice {
friend class DeviceManagement;
public:
static NonnullLockRefPtr<KCOVDevice> must_create();
static void free_thread();
static void free_process();
// ^File
ErrorOr<NonnullLockRefPtr<Memory::VMObject>> vmobject_for_mmap(Process&, Memory::VirtualRange const&, u64& offset, bool shared) override;
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
protected:
KCOVDevice();
virtual StringView class_name() const override { return "KCOVDevice"sv; }
virtual bool can_read(OpenFileDescription const&, u64) const override final { return true; }
virtual bool can_write(OpenFileDescription const&, u64) const override final { return true; }
virtual void start_request(AsyncBlockDeviceRequest& request) override final { request.complete(AsyncDeviceRequest::Failure); }
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; }
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; }
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
};
}