/* * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include "EventSerialNumber.h" #include #include #include #include #include #include namespace Profiler { struct MappedObject { NonnullRefPtr file; ELF::Image elf; }; extern HashMap> g_mapped_object_cache; class LibraryMetadata { public: struct Library { FlatPtr base; size_t size; DeprecatedString name; MappedObject* object { nullptr }; // This is loaded lazily because we only need it in disassembly view mutable OwnPtr debug_info; DeprecatedString symbolicate(FlatPtr, u32* offset) const; Debug::DebugInfo const& load_debug_info(FlatPtr base_address) const; }; void handle_mmap(FlatPtr base, size_t size, DeprecatedString const& name); Library const* library_containing(FlatPtr) const; private: mutable HashMap> m_libraries; }; struct Thread { pid_t tid; EventSerialNumber start_valid; EventSerialNumber end_valid; bool valid_at(EventSerialNumber serial) const { return serial >= start_valid && (end_valid == EventSerialNumber {} || serial <= end_valid); } }; struct Process { pid_t pid {}; DeprecatedString executable; DeprecatedString basename; HashMap> threads {}; LibraryMetadata library_metadata {}; EventSerialNumber start_valid; EventSerialNumber end_valid; Thread* find_thread(pid_t tid, EventSerialNumber serial); void handle_thread_create(pid_t tid, EventSerialNumber serial); void handle_thread_exit(pid_t tid, EventSerialNumber serial); bool valid_at(EventSerialNumber serial) const { return serial >= start_valid && (end_valid == EventSerialNumber {} || serial <= end_valid); } }; }