//===-- Perf.h --------------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// This file contains a thin wrapper of the perf_event_open API /// and classes to handle the destruction of file descriptors /// and mmap pointers. /// //===----------------------------------------------------------------------===// #ifndef LLDB_SOURCE_PLUGINS_PROCESS_LINUX_PERF_H #define LLDB_SOURCE_PLUGINS_PROCESS_LINUX_PERF_H #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h" #include "lldb/lldb-types.h" #include "llvm/Support/Error.h" #include <chrono> #include <cstdint> #include <linux/perf_event.h> namespace lldb_private { namespace process_linux { namespace resource_handle { /// Custom deleter for the pointer returned by \a mmap. /// /// This functor type is provided to \a unique_ptr to properly /// unmap the region at destruction time. class MmapDeleter { … }; /// Custom deleter for a file descriptor. /// /// This functor type is provided to \a unique_ptr to properly release /// the resources associated with the file descriptor at destruction time. class FileDescriptorDeleter { … }; FileDescriptorUP; MmapUP; } // namespace resource_handle /// Thin wrapper of the perf_event_open API. /// /// Exposes the metadata page and data and aux buffers of a perf event. /// Handles the management of the event's file descriptor and mmap'ed /// regions. class PerfEvent { … }; /// Create a perf event that tracks context switches on a cpu. /// /// \param[in] cpu_id /// The core to trace. /// /// \param[in] parent_perf_event /// An optional perf event that will be grouped with the /// new perf event. llvm::Expected<PerfEvent> CreateContextSwitchTracePerfEvent(lldb::cpu_id_t cpu_id, const PerfEvent *parent_perf_event = nullptr); /// Load \a PerfTscConversionParameters from \a perf_event_mmap_page, if /// available. llvm::Expected<LinuxPerfZeroTscConversion> LoadPerfTscConversionParameters(); } // namespace process_linux } // namespace lldb_private #endif // LLDB_SOURCE_PLUGINS_PROCESS_LINUX_PERF_H