Summary: Not once have I looked at these numbers in a log and considered them useful. Also this should not have been implemented via an unguarded list of globals.
Reviewers: martong, shafik
Reviewed By: shafik
Subscribers: rnkovacs, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D71336
namespace lldb_private {
-class ClangASTMetrics {
-public:
- static void DumpCounters(Log *log);
- static void ClearLocalCounters() { local_counters = {0, 0, 0, 0, 0, 0}; }
-
- static void RegisterVisibleQuery() {
- ++global_counters.m_visible_query_count;
- ++local_counters.m_visible_query_count;
- }
-
- static void RegisterLexicalQuery() {
- ++global_counters.m_lexical_query_count;
- ++local_counters.m_lexical_query_count;
- }
-
- static void RegisterLLDBImport() {
- ++global_counters.m_lldb_import_count;
- ++local_counters.m_lldb_import_count;
- }
-
- static void RegisterClangImport() {
- ++global_counters.m_clang_import_count;
- ++local_counters.m_clang_import_count;
- }
-
- static void RegisterDeclCompletion() {
- ++global_counters.m_decls_completed_count;
- ++local_counters.m_decls_completed_count;
- }
-
- static void RegisterRecordLayout() {
- ++global_counters.m_record_layout_count;
- ++local_counters.m_record_layout_count;
- }
-
-private:
- struct Counters {
- uint64_t m_visible_query_count;
- uint64_t m_lexical_query_count;
- uint64_t m_lldb_import_count;
- uint64_t m_clang_import_count;
- uint64_t m_decls_completed_count;
- uint64_t m_record_layout_count;
- };
-
- static Counters global_counters;
- static Counters local_counters;
-
- static void DumpCounters(Log *log, Counters &counters);
-};
-
class ClangASTImporter {
public:
struct LayoutInfo {
} else if (!m_ast_importer_sp)
return;
- ClangASTMetrics::RegisterLexicalQuery();
-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
const Decl *context_decl = dyn_cast<Decl>(decl_context);
void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
assert(m_ast_context);
- ClangASTMetrics::RegisterVisibleQuery();
-
const ConstString name(context.m_decl_name.getAsString().c_str());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
FieldOffsetMap &field_offsets,
BaseOffsetMap &base_offsets,
BaseOffsetMap &virtual_base_offsets) {
- ClangASTMetrics::RegisterRecordLayout();
-
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
if (src_ast == nullptr)
return CompilerType();
- ClangASTMetrics::RegisterLLDBImport();
-
SetImportInProgress(true);
QualType copied_qual_type;
bool ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
Materializer *materializer) {
- ClangASTMetrics::ClearLocalCounters();
-
EnableParserVars();
m_parser_vars->m_exe_ctx = exe_ctx;
}
void ClangExpressionDeclMap::DidParse() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
- if (log)
- ClangASTMetrics::DumpCounters(log);
-
if (m_parser_vars) {
for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
entity_index < num_entities; ++entity_index) {
NameSearchContext &context) {
assert(m_ast_context);
- ClangASTMetrics::RegisterVisibleQuery();
-
const ConstString name(context.m_decl_name.getAsString().c_str());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
using namespace lldb_private;
using namespace clang;
-ClangASTMetrics::Counters ClangASTMetrics::global_counters = {0, 0, 0, 0, 0, 0};
-ClangASTMetrics::Counters ClangASTMetrics::local_counters = {0, 0, 0, 0, 0, 0};
-
-void ClangASTMetrics::DumpCounters(Log *log,
- ClangASTMetrics::Counters &counters) {
- LLDB_LOGF(log, " Number of visible Decl queries by name : %" PRIu64,
- counters.m_visible_query_count);
- LLDB_LOGF(log, " Number of lexical Decl queries : %" PRIu64,
- counters.m_lexical_query_count);
- LLDB_LOGF(log, " Number of imports initiated by LLDB : %" PRIu64,
- counters.m_lldb_import_count);
- LLDB_LOGF(log, " Number of imports conducted by Clang : %" PRIu64,
- counters.m_clang_import_count);
- LLDB_LOGF(log, " Number of Decls completed : %" PRIu64,
- counters.m_decls_completed_count);
- LLDB_LOGF(log, " Number of records laid out : %" PRIu64,
- counters.m_record_layout_count);
-}
-
-void ClangASTMetrics::DumpCounters(Log *log) {
- if (!log)
- return;
-
- LLDB_LOGF(log, "== ClangASTMetrics output ==");
- LLDB_LOGF(log, "-- Global metrics --");
- DumpCounters(log, global_counters);
- LLDB_LOGF(log, "-- Local metrics --");
- DumpCounters(log, local_counters);
-}
-
clang::QualType ClangASTImporter::CopyType(clang::ASTContext *dst_ast,
clang::ASTContext *src_ast,
clang::QualType type) {
}
bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {
- ClangASTMetrics::RegisterDeclCompletion();
-
DeclOrigin decl_origin = GetDeclOrigin(decl);
if (!decl_origin.Valid())
bool ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl,
clang::TagDecl *origin_decl) {
- ClangASTMetrics::RegisterDeclCompletion();
-
clang::ASTContext *origin_ast_ctx = &origin_decl->getASTContext();
if (!ClangASTContext::GetCompleteDecl(origin_ast_ctx, origin_decl))
bool ClangASTImporter::CompleteObjCInterfaceDecl(
clang::ObjCInterfaceDecl *interface_decl) {
- ClangASTMetrics::RegisterDeclCompletion();
-
DeclOrigin decl_origin = GetDeclOrigin(interface_decl);
if (!decl_origin.Valid())
void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
clang::Decl *to) {
- ClangASTMetrics::RegisterClangImport();
-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
// Some decls shouldn't be tracked here because they were not created by