1314564Sdim//===-- JITLoaderList.cpp ---------------------------------------*- C++ -*-===// 2275072Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6275072Semaste// 7275072Semaste//===----------------------------------------------------------------------===// 8275072Semaste 9275072Semaste#include "lldb/Target/JITLoader.h" 10275072Semaste#include "lldb/Target/JITLoaderList.h" 11314564Sdim#include "lldb/lldb-private.h" 12275072Semaste 13275072Semasteusing namespace lldb; 14275072Semasteusing namespace lldb_private; 15275072Semaste 16314564SdimJITLoaderList::JITLoaderList() : m_jit_loaders_vec(), m_jit_loaders_mutex() {} 17275072Semaste 18314564SdimJITLoaderList::~JITLoaderList() {} 19275072Semaste 20314564Sdimvoid JITLoaderList::Append(const JITLoaderSP &jit_loader_sp) { 21314564Sdim std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 22314564Sdim m_jit_loaders_vec.push_back(jit_loader_sp); 23275072Semaste} 24275072Semaste 25314564Sdimvoid JITLoaderList::Remove(const JITLoaderSP &jit_loader_sp) { 26314564Sdim std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 27314564Sdim m_jit_loaders_vec.erase(std::remove(m_jit_loaders_vec.begin(), 28314564Sdim m_jit_loaders_vec.end(), jit_loader_sp), 29314564Sdim m_jit_loaders_vec.end()); 30275072Semaste} 31275072Semaste 32314564Sdimsize_t JITLoaderList::GetSize() const { return m_jit_loaders_vec.size(); } 33275072Semaste 34314564SdimJITLoaderSP JITLoaderList::GetLoaderAtIndex(size_t idx) { 35314564Sdim std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 36314564Sdim return m_jit_loaders_vec[idx]; 37275072Semaste} 38275072Semaste 39314564Sdimvoid JITLoaderList::DidLaunch() { 40314564Sdim std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 41314564Sdim for (auto const &jit_loader : m_jit_loaders_vec) 42314564Sdim jit_loader->DidLaunch(); 43275072Semaste} 44275072Semaste 45314564Sdimvoid JITLoaderList::DidAttach() { 46314564Sdim std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 47314564Sdim for (auto const &jit_loader : m_jit_loaders_vec) 48314564Sdim jit_loader->DidAttach(); 49275072Semaste} 50275072Semaste 51314564Sdimvoid JITLoaderList::ModulesDidLoad(ModuleList &module_list) { 52314564Sdim std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 53314564Sdim for (auto const &jit_loader : m_jit_loaders_vec) 54314564Sdim jit_loader->ModulesDidLoad(module_list); 55275072Semaste} 56