1 //===-- JITLoaderList.cpp -------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/JITLoader.h"
10 #include "lldb/Target/JITLoaderList.h"
11 #include "lldb/lldb-private.h"
14 using namespace lldb_private
;
16 JITLoaderList::JITLoaderList() : m_jit_loaders_vec(), m_jit_loaders_mutex() {}
18 JITLoaderList::~JITLoaderList() = default;
20 void JITLoaderList::Append(const JITLoaderSP
&jit_loader_sp
) {
21 std::lock_guard
<std::recursive_mutex
> guard(m_jit_loaders_mutex
);
22 m_jit_loaders_vec
.push_back(jit_loader_sp
);
25 void JITLoaderList::Remove(const JITLoaderSP
&jit_loader_sp
) {
26 std::lock_guard
<std::recursive_mutex
> guard(m_jit_loaders_mutex
);
27 m_jit_loaders_vec
.erase(std::remove(m_jit_loaders_vec
.begin(),
28 m_jit_loaders_vec
.end(), jit_loader_sp
),
29 m_jit_loaders_vec
.end());
32 size_t JITLoaderList::GetSize() const { return m_jit_loaders_vec
.size(); }
34 JITLoaderSP
JITLoaderList::GetLoaderAtIndex(size_t idx
) {
35 std::lock_guard
<std::recursive_mutex
> guard(m_jit_loaders_mutex
);
36 return m_jit_loaders_vec
[idx
];
39 void JITLoaderList::DidLaunch() {
40 std::lock_guard
<std::recursive_mutex
> guard(m_jit_loaders_mutex
);
41 for (auto const &jit_loader
: m_jit_loaders_vec
)
42 jit_loader
->DidLaunch();
45 void JITLoaderList::DidAttach() {
46 std::lock_guard
<std::recursive_mutex
> guard(m_jit_loaders_mutex
);
47 for (auto const &jit_loader
: m_jit_loaders_vec
)
48 jit_loader
->DidAttach();
51 void JITLoaderList::ModulesDidLoad(ModuleList
&module_list
) {
52 std::lock_guard
<std::recursive_mutex
> guard(m_jit_loaders_mutex
);
53 for (auto const &jit_loader
: m_jit_loaders_vec
)
54 jit_loader
->ModulesDidLoad(module_list
);