16#include "llvm/ADT/StringMap.h"
27 return lhs.
id < rhs.
id;
31 std::lock_guard<std::mutex> guard(
m_mutex);
40 std::lock_guard<std::mutex> guard(
m_mutex);
44std::vector<ScriptedInstanceInfo>
46 std::lock_guard<std::mutex> guard(
m_mutex);
47 std::vector<ScriptedInstanceInfo> instances;
50 instances.push_back(entry.second);
54std::vector<ScriptedInstanceInfo>
56 std::vector<ScriptedInstanceInfo> instances =
CopyInstances();
68 if (path != other_path)
69 return path < other_path;
75 llvm::ArrayRef<ScriptedExtension> extensions)
const {
77 llvm::StringMap<ScriptedExtension> extension_by_plugin;
82 std::vector<ScriptedInstanceGroup> groups;
85 if (!extensions.empty() && !llvm::is_contained(extensions, extension))
93 if (it == groups.end()) {
95 it->class_name = info.class_name;
96 it->extension = extension;
97 it->source_path = info.source_path;
99 it->instances.push_back(std::move(info));
109 auto group_sp = std::make_shared<StructuredData::Dictionary>();
110 group_sp->AddStringItem(
"class_name",
class_name);
111 group_sp->AddStringItem(
"extension",
114 group_sp->AddStringItem(
"source_path",
source_path.GetPath());
116 auto instances_sp = std::make_shared<StructuredData::Array>();
118 auto instance_sp = std::make_shared<StructuredData::Dictionary>();
119 instance_sp->AddStringItem(
"uuid", info.uuid.GetAsString());
121 instance_sp->AddIntegerItem(
"address", info.object_address);
123 instance_sp->AddItem(
"args", info.args_sp);
124 instances_sp->AddItem(instance_sp);
126 group_sp->AddItem(
"instances", instances_sp);
131 bool use_color)
const {
132 auto ansi_code = [use_color](llvm::StringRef code) {
140 auto print_label = [&](llvm::StringRef indent, llvm::StringRef label) {
141 s << indent << label_prefix << label <<
':' << label_suffix;
144 s << info.uuid.GetAsString();
146 s.
Format(
" ({0:x})", info.object_address);
150 llvm::StringRef indent) {
153 print_label(indent,
"Args");
157 s << indent <<
" - " << key <<
": ";
159 s << str->GetValue();
161 value->
Dump(s,
false);
167 print_label(
" ",
"Class");
168 s <<
' ' << title_prefix <<
class_name << title_suffix <<
'\n';
169 print_label(
" ",
"Extension");
172 print_label(
" ",
"Path");
177 print_label(
" ",
"Instance");
184 print_label(
" ",
"Instances");
186 for (
auto [idx, info] : llvm::enumerate(
instances)) {
188 print_instance(info);
189 print_args(info,
" ");
static bool HasArgs(const ScriptedInstanceInfo &info)
static bool CreatedBefore(const ScriptedInstanceInfo &lhs, const ScriptedInstanceInfo &rhs)
A class to manage flag bits.
llvm::StringRef GetLabelAnsiSuffix() const
llvm::StringRef GetTitleAnsiPrefix() const
llvm::StringRef GetTitleAnsiSuffix() const
llvm::StringRef GetLabelAnsiPrefix() const
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
static size_t GetNumScriptedInterfaces()
static lldb::ScriptedExtension GetScriptedInterfaceExtensionAtIndex(uint32_t idx)
static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx)
static llvm::StringLiteral ExtensionToString(lldb::ScriptedExtension extension)
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.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
void Dump(lldb_private::Stream &s, bool pretty_print=true) const
std::shared_ptr< Dictionary > DictionarySP
static UUID Generate(uint32_t num_bytes=16)
Create a random UUID.
#define LLDB_INVALID_ADDRESS
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
A class that represents a running process on the host machine.
ScriptedExtension
Scripting extension types.
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
lldb::ScriptedExtension extension
StructuredData::DictionarySP args_sp