Skip to content

Commit 0aad1f6

Browse files
committed
Include plugin info in stats
1 parent 9b41e47 commit 0aad1f6

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

lldb/include/lldb/Target/Statistics.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,21 @@ struct StatisticsOptions {
174174
return !GetSummaryOnly();
175175
}
176176

177+
void SetIncludePlugins(bool value) { m_include_plugins = value; }
178+
bool GetIncludePlugins() const {
179+
if (m_include_plugins.has_value())
180+
return m_include_plugins.value();
181+
// Default to true in both default mode and summary mode.
182+
return true;
183+
}
184+
177185
private:
178186
std::optional<bool> m_summary_only;
179187
std::optional<bool> m_load_all_debug_info;
180188
std::optional<bool> m_include_targets;
181189
std::optional<bool> m_include_modules;
182190
std::optional<bool> m_include_transcript;
191+
std::optional<bool> m_include_plugins;
183192
};
184193

185194
/// A class that represents statistics about a TypeSummaryProviders invocations

lldb/source/Commands/CommandObjectStats.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ class CommandObjectStatsDump : public CommandObjectParsed {
103103
else
104104
error = Status::FromError(bool_or_error.takeError());
105105
break;
106+
case 'p':
107+
if (llvm::Expected<bool> bool_or_error =
108+
OptionArgParser::ToBoolean("--plugins", option_arg))
109+
m_stats_options.SetIncludePlugins(*bool_or_error);
110+
else
111+
error = Status::FromError(bool_or_error.takeError());
112+
break;
106113
default:
107114
llvm_unreachable("Unimplemented option");
108115
}

lldb/source/Commands/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,5 +1467,9 @@ let Command = "statistics dump" in {
14671467
"scripts executed during a debug session. "
14681468
"Defaults to true, unless the '--summary' mode is enabled, in which case "
14691469
"this is turned off unless specified.">;
1470+
def statistics_dump_plugins: Option<"plugins", "p">, Group<1>,
1471+
Arg<"Boolean">,
1472+
Desc<"Dump statistics for known plugins including name, order, and enabled "
1473+
"state. Defaults to true for both summary and default mode.">;
14701474

14711475
}

lldb/source/Target/Statistics.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "lldb/Core/Debugger.h"
1212
#include "lldb/Core/Module.h"
13+
#include "lldb/Core/PluginManager.h"
1314
#include "lldb/Interpreter/CommandInterpreter.h"
1415
#include "lldb/Symbol/SymbolFile.h"
1516
#include "lldb/Target/DynamicLoader.h"
@@ -285,6 +286,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(
285286
const bool include_targets = options.GetIncludeTargets();
286287
const bool include_modules = options.GetIncludeModules();
287288
const bool include_transcript = options.GetIncludeTranscript();
289+
const bool include_plugins = options.GetIncludePlugins();
288290

289291
json::Array json_targets;
290292
json::Array json_modules;
@@ -464,6 +466,23 @@ llvm::json::Value DebuggerStats::ReportStatistics(
464466
}
465467
}
466468

469+
if (include_plugins) {
470+
json::Object plugin_stats;
471+
for (const PluginNamespace &plugin_ns : PluginManager::GetPluginNamespaces()) {
472+
json::Array namespace_stats;
473+
474+
for (const RegisteredPluginInfo &plugin : plugin_ns.get_info()) {
475+
json::Object plugin_json;
476+
plugin_json.try_emplace("name", plugin.name);
477+
plugin_json.try_emplace("enabled", plugin.enabled);
478+
479+
namespace_stats.emplace_back(std::move(plugin_json));
480+
}
481+
plugin_stats.try_emplace(plugin_ns.name, std::move(namespace_stats));
482+
}
483+
global_stats.try_emplace("plugins", std::move(plugin_stats));
484+
}
485+
467486
return std::move(global_stats);
468487
}
469488

0 commit comments

Comments
 (0)