LLDB mainline
TargetGroupList.h
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
9#ifndef LLDB_TARGET_TARGETGROUPLIST_H
10#define LLDB_TARGET_TARGETGROUPLIST_H
11
13
14#include <memory>
15#include <mutex>
16#include <vector>
17
18namespace lldb_private {
19
20/// A thread-safe collection of target groups. A Debugger uses one as its
21/// registry, and each Target uses one for the groups it belongs to.
23private:
24 friend class Debugger;
25 friend class Target;
26
27 explicit TargetGroupList(Debugger &debugger)
28 : m_debugger(debugger),
29 m_mutex(std::make_shared<std::recursive_mutex>()) {}
30
32 const std::shared_ptr<std::recursive_mutex> &mutex)
33 : m_debugger(debugger), m_mutex(mutex) {}
34
35public:
37
42
43 lldb::TargetGroupSP CreateTargetGroup(llvm::StringRef description);
44
45 /// Remove \p group_sp from this list. Other shared references, including
46 /// target membership lists, remain valid.
47 bool DeleteTargetGroup(const lldb::TargetGroupSP &group_sp);
48
49 /// Return a snapshot of the target groups. Modifying the returned vector
50 /// does not modify this list.
51 std::vector<lldb::TargetGroupSP> GetGroups() const;
52
53private:
54 friend class TargetGroup;
55
56 void Add(const lldb::TargetGroupSP &group_sp);
57 void Remove(const TargetGroup *group);
58 void Clear();
59 void RemoveTarget(const lldb::TargetSP &target_sp);
60
62 /// Shared by the debugger's list, each target's list, and every group.
63 /// Group membership operations never acquire Target::m_mutex.
64 std::shared_ptr<std::recursive_mutex> m_mutex;
65 std::vector<lldb::TargetGroupSP> m_groups;
66};
67
68} // namespace lldb_private
69
70#endif // LLDB_TARGET_TARGETGROUPLIST_H
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)
TargetGroupList(Debugger &debugger)
TargetGroupList(TargetGroupList &&)=delete
TargetGroupList & operator=(const TargetGroupList &)=delete
void Add(const lldb::TargetGroupSP &group_sp)
TargetGroupList(const TargetGroupList &)=delete
std::shared_ptr< std::recursive_mutex > m_mutex
Shared by the debugger's list, each target's list, and every group.
TargetGroupList(Debugger &debugger, const std::shared_ptr< std::recursive_mutex > &mutex)
std::vector< lldb::TargetGroupSP > GetGroups() const
Return a snapshot of the target groups.
std::vector< lldb::TargetGroupSP > m_groups
TargetGroupList & operator=(TargetGroupList &&)=delete
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