LLDB mainline
ScriptedInstanceRegistry.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_INTERPRETER_SCRIPTEDINSTANCEREGISTRY_H
10#define LLDB_INTERPRETER_SCRIPTEDINSTANCEREGISTRY_H
11
14#include "lldb/Utility/UUID.h"
15#include "lldb/lldb-defines.h"
17#include "lldb/lldb-forward.h"
18#include "lldb/lldb-types.h"
19#include "llvm/ADT/ArrayRef.h"
20#include "llvm/ADT/DenseMap.h"
21#include "llvm/ADT/StringRef.h"
22
23#include <cstdint>
24#include <mutex>
25#include <string>
26#include <vector>
27
28namespace lldb_private {
29
31 uint64_t id = 0;
34 /// The interface's PluginManager name, from the string literal its
35 /// GetPluginNameStatic() returns, so this never dangles.
36 llvm::StringRef plugin_name;
37 std::string class_name;
40};
41
42/// The live instances of one extension class. Instances belong to the same
43/// group when they share a class name, source path and extension kind, so a
44/// class reused for several kinds of extension gets one group per kind.
46 std::string class_name;
49 std::vector<ScriptedInstanceInfo> instances;
50
51 bool operator<(const ScriptedInstanceGroup &other) const;
52
54
55 void Dump(Stream &s, const Debugger &debugger, bool use_color) const;
56};
57
58/// Entries are snapshots taken when the object is created, so listing them
59/// never calls back into an interface that might be mid-destruction on
60/// another thread.
62public:
63 uint64_t Add(ScriptedInstanceInfo info);
64
65 void Remove(uint64_t id);
66
67 std::vector<ScriptedInstanceInfo> GetInstances() const;
68
69 std::vector<ScriptedInstanceGroup> GetInstanceGroups(
70 llvm::ArrayRef<lldb::ScriptedExtension> extensions = {}) const;
71
72private:
73 std::vector<ScriptedInstanceInfo> CopyInstances() const;
74
75 mutable std::mutex m_mutex;
76 uint64_t m_next_id = 1;
77 llvm::DenseMap<uint64_t, ScriptedInstanceInfo> m_instances;
78};
79
80} // namespace lldb_private
81
82#endif // LLDB_INTERPRETER_SCRIPTEDINSTANCEREGISTRY_H
A class to manage flag bits.
Definition Debugger.h:101
A file utility class.
Definition FileSpec.h:56
Entries are snapshots taken when the object is created, so listing them never calls back into an inte...
std::vector< ScriptedInstanceInfo > CopyInstances() const
std::vector< ScriptedInstanceInfo > GetInstances() const
uint64_t Add(ScriptedInstanceInfo info)
std::vector< ScriptedInstanceGroup > GetInstanceGroups(llvm::ArrayRef< lldb::ScriptedExtension > extensions={}) const
llvm::DenseMap< uint64_t, ScriptedInstanceInfo > m_instances
A stream class that can stream formatted output to a file.
Definition Stream.h:28
std::shared_ptr< Dictionary > DictionarySP
Represents UUID's of various sizes.
Definition UUID.h:27
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
ScriptedExtension
Scripting extension types.
@ eScriptedExtensionInvalid
uint64_t addr_t
Definition lldb-types.h:80
The live instances of one extension class.
bool operator<(const ScriptedInstanceGroup &other) const
void Dump(Stream &s, const Debugger &debugger, bool use_color) const
StructuredData::DictionarySP ToStructuredData() const
std::vector< ScriptedInstanceInfo > instances
llvm::StringRef plugin_name
The interface's PluginManager name, from the string literal its GetPluginNameStatic() returns,...