[Lldb-commits] [lldb] 13cd390 - [lldb] Add information on type systems to statistics dump command
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 2 10:46:19 PDT 2022
Author: Alex Langford
Date: 2022-11-02T10:45:56-07:00
New Revision: 13cd39017de07a116c8901904fd4cf7aa290a47c
URL: https://github.com/llvm/llvm-project/commit/13cd39017de07a116c8901904fd4cf7aa290a47c
DIFF: https://github.com/llvm/llvm-project/commit/13cd39017de07a116c8901904fd4cf7aa290a47c.diff
LOG: [lldb] Add information on type systems to statistics dump command
Context: I plan on using this change primarily downstream in the apple
fork of llvm to track swift module loading time.
Reviewed By: clayborg, tschuett
Differential Revision: https://reviews.llvm.org/D137191
Added:
Modified:
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/include/lldb/Target/Statistics.h
lldb/source/Core/Module.cpp
lldb/source/Symbol/TypeSystem.cpp
lldb/source/Target/Statistics.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index e877a14dcda10..523e04c6e6b4c 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -29,6 +29,7 @@
#include "lldb/lldb-types.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Chrono.h"
@@ -814,6 +815,8 @@ class Module : public std::enable_shared_from_this<Module>,
llvm::Expected<TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language);
+ void ForEachTypeSystem(llvm::function_ref<bool(TypeSystem *)> callback);
+
// Special error functions that can do printf style formatting that will
// prepend the message with something appropriate for this module (like the
// architecture, path and object name (if any)). This centralizes code so
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index fd31b130c4ffd..0da0e35a4f9ca 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -19,6 +19,7 @@
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/JSON.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Expression/Expression.h"
@@ -508,6 +509,8 @@ class TypeSystem : public PluginInterface {
// meaningless type itself, instead preferring to use the dynamic type
virtual bool IsMeaninglessWithoutDynamicResolution(void *type);
+ virtual llvm::Optional<llvm::json::Value> ReportStatistics();
+
protected:
SymbolFile *m_sym_file = nullptr;
};
diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h
index db6494ce7899e..4bf2f3a69c9b1 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -12,6 +12,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Stream.h"
#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringMap.h"
#include "llvm/Support/JSON.h"
#include <atomic>
#include <chrono>
@@ -107,6 +108,7 @@ struct ModuleStats {
// identifiers of these modules in the global module list. This allows us to
// track down all of the stats that contribute to this module.
std::vector<intptr_t> symfile_modules;
+ llvm::StringMap<llvm::json::Value> type_system_stats;
double symtab_parse_time = 0.0;
double symtab_index_time = 0.0;
double debug_parse_time = 0.0;
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index d5b4621880dcd..20bd02f101fcc 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -369,6 +369,11 @@ Module::GetTypeSystemForLanguage(LanguageType language) {
return m_type_system_map.GetTypeSystemForLanguage(language, this, true);
}
+void Module::ForEachTypeSystem(
+ llvm::function_ref<bool(TypeSystem *)> callback) {
+ m_type_system_map.ForEach(callback);
+}
+
void Module::ParseAllDebugSymbols() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
size_t num_comp_units = GetNumCompileUnits();
diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp
index 412373533aaba..ae5ae5cbd659a 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -178,6 +178,10 @@ TypeSystem::CreateUtilityFunction(std::string text, std::string name) {
return {};
}
+llvm::Optional<llvm::json::Value> TypeSystem::ReportStatistics() {
+ return llvm::None;
+}
+
#pragma mark TypeSystemMap
TypeSystemMap::TypeSystemMap() : m_mutex(), m_map() {}
diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp
index 0ea09743d1300..118d6c396172c 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -75,6 +75,17 @@ json::Value ModuleStats::ToJSON() const {
symfile_ids.emplace_back(symfile_id);
module.try_emplace("symbolFileModuleIdentifiers", std::move(symfile_ids));
}
+
+ if (!type_system_stats.empty()) {
+ json::Array type_systems;
+ for (const auto &entry : type_system_stats) {
+ json::Object obj;
+ obj.try_emplace(entry.first().str(), entry.second);
+ type_systems.emplace_back(std::move(obj));
+ }
+ module.try_emplace("typeSystemInfo", std::move(type_systems));
+ }
+
return module;
}
@@ -256,6 +267,11 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
debug_parse_time += module_stat.debug_parse_time;
debug_index_time += module_stat.debug_index_time;
debug_info_size += module_stat.debug_info_size;
+ module->ForEachTypeSystem([&](TypeSystem *ts) {
+ if (auto stats = ts->ReportStatistics())
+ module_stat.type_system_stats.insert({ts->GetPluginName(), *stats});
+ return true;
+ });
json_modules.emplace_back(module_stat.ToJSON());
}
More information about the lldb-commits
mailing list