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 return CreateTargetGroup<TargetGroup>(description);
20}
21
23 if (!group_sp)
24 return false;
25
26 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
27 auto it = llvm::find(m_groups, group_sp);
28 if (it == m_groups.end())
29 return false;
30 m_groups.erase(it);
31 return true;
32}
33
34std::vector<TargetGroupSP> TargetGroupList::GetGroups() const {
35 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
36 return m_groups;
37}
38
39void TargetGroupList::Add(const TargetGroupSP &group_sp) {
40 if (!group_sp)
41 return;
42
43 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
44 if (!llvm::is_contained(m_groups, group_sp))
45 m_groups.push_back(group_sp);
46}
47
49 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
50 llvm::erase_if(m_groups, [group](const TargetGroupSP &group_sp) {
51 return group_sp.get() == group;
52 });
53}
54
56 if (!target_sp)
57 return;
58
59 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
60 std::vector<TargetGroupSP> groups = m_groups;
61 for (const TargetGroupSP &group_sp : groups) {
62 group_sp->RemoveTarget(target_sp);
63 if (group_sp->GetTargets().empty())
64 m_debugger.GetTargetGroupList().DeleteTargetGroup(group_sp);
65 }
66 m_groups.clear();
67}
68
70 std::lock_guard<std::recursive_mutex> guard(*m_mutex);
71 m_groups.clear();
72}
lldb::TargetGroupSP CreateTargetGroup(llvm::StringRef description)
Create and register a target group.
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