LLDB mainline
TargetGroupList.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Debugger.h"
11#include "llvm/ADT/STLExtras.h"
12
13using namespace lldb;
14using namespace lldb_private;
15
17
19 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
20 TargetGroupSP group_sp(
21 new TargetGroup(m_debugger.shared_from_this(), description, m_mutex));
22 m_groups.push_back(group_sp);
23 return group_sp;
24}
25
27 if (!group_sp)
28 return false;
29
30 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
31 auto it = llvm::find(m_groups, group_sp);
32 if (it == m_groups.end())
33 return false;
34 m_groups.erase(it);
35 return true;
36}
37
38std::vector<TargetGroupSP> TargetGroupList::GetGroups() const {
39 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
40 return m_groups;
41}
42
43void TargetGroupList::Add(const TargetGroupSP &group_sp) {
44 if (!group_sp)
45 return;
46
47 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
48 if (!llvm::is_contained(m_groups, group_sp))
49 m_groups.push_back(group_sp);
50}
51
53 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
54 llvm::erase_if(m_groups, [group](const TargetGroupSP &group_sp) {
55 return group_sp.get() == group;
56 });
57}
58
60 if (!target_sp)
61 return;
62
63 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
64 std::vector<TargetGroupSP> groups = m_groups;
65 for (const TargetGroupSP &group_sp : groups)
66 group_sp->RemoveTarget(target_sp);
67 m_groups.clear();
68}
69
71 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
72 m_groups.clear();
73}
lldb::TargetGroupSP CreateTargetGroup(llvm::StringRef description)
bool DeleteTargetGroup(const lldb::TargetGroupSP &group_sp)
Remove group_sp from this list.
void RemoveTarget(const lldb::TargetSP &target_sp)
void Remove(const TargetGroup *group)
void Add(const lldb::TargetGroupSP &group_sp)
std::shared_ptr< std::recursive_mutex > m_mutex
Shared by the debugger's list, each target's list, and every group.
std::vector< lldb::TargetGroupSP > GetGroups() const
Return a snapshot of the target groups.
std::vector< lldb::TargetGroupSP > m_groups
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::TargetGroup > TargetGroupSP
std::shared_ptr< lldb_private::Target > TargetSP