1 //===-- JITLoader.cpp -------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/lldb-private.h" 11 #include "lldb/Target/JITLoader.h" 12 #include "lldb/Target/JITLoaderList.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 17 JITLoaderList::JITLoaderList() : m_jit_loaders_vec(), m_jit_loaders_mutex() 18 { 19 } 20 21 JITLoaderList::~JITLoaderList() 22 { 23 } 24 25 void 26 JITLoaderList::Append (const JITLoaderSP &jit_loader_sp) 27 { 28 std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 29 m_jit_loaders_vec.push_back(jit_loader_sp); 30 } 31 32 void 33 JITLoaderList::Remove (const JITLoaderSP &jit_loader_sp) 34 { 35 std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 36 m_jit_loaders_vec.erase(std::remove(m_jit_loaders_vec.begin(), 37 m_jit_loaders_vec.end(), jit_loader_sp), 38 m_jit_loaders_vec.end()); 39 } 40 41 size_t 42 JITLoaderList::GetSize() const 43 { 44 return m_jit_loaders_vec.size(); 45 } 46 47 JITLoaderSP 48 JITLoaderList::GetLoaderAtIndex (size_t idx) 49 { 50 std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 51 return m_jit_loaders_vec[idx]; 52 } 53 54 void 55 JITLoaderList::DidLaunch() 56 { 57 std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 58 for (auto const &jit_loader : m_jit_loaders_vec) 59 jit_loader->DidLaunch(); 60 } 61 62 void 63 JITLoaderList::DidAttach() 64 { 65 std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 66 for (auto const &jit_loader : m_jit_loaders_vec) 67 jit_loader->DidAttach(); 68 } 69 70 void 71 JITLoaderList::ModulesDidLoad(ModuleList &module_list) 72 { 73 std::lock_guard<std::recursive_mutex> guard(m_jit_loaders_mutex); 74 for (auto const &jit_loader : m_jit_loaders_vec) 75 jit_loader->ModulesDidLoad(module_list); 76 } 77