From: Douglas Gregor Date: Thu, 21 Jul 2011 19:50:14 +0000 (+0000) Subject: Add some debugging output to the AST reader, so we can see the global remappings... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23d7df5ce30f4a068e13ad6cb81d473365d260db;p=clang Add some debugging output to the AST reader, so we can see the global remappings we generate git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135701 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index ae666b717a..d7b574a774 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1169,6 +1169,9 @@ public: /// \brief Print some statistics about AST usage. virtual void PrintStats(); + /// \brief Dump information about the AST reader to standard error. + void dump(); + /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 83c894b648..be2b79d403 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -4277,6 +4277,60 @@ void ASTReader::PrintStats() { std::fprintf(stderr, " %u method pool misses\n", NumMethodPoolMisses); } std::fprintf(stderr, "\n"); + dump(); + std::fprintf(stderr, "\n"); +} + +template +static void +dumpModuleIDMap(llvm::StringRef Name, + const ContinuousRangeMap &Map) { + if (Map.begin() == Map.end()) + return; + + typedef ContinuousRangeMap MapType; + llvm::errs() << Name << ":\n"; + for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); + I != IEnd; ++I) { + llvm::errs() << " " << I->first << " -> " << I->second->FileName + << "\n"; + } +} + +template +static void +dumpModuleIDOffsetMap(llvm::StringRef Name, + const ContinuousRangeMap, + InitialCapacity> &Map) { + if (Map.begin() == Map.end()) + return; + + typedef ContinuousRangeMap, + InitialCapacity> MapType; + llvm::errs() << Name << ":\n"; + for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); + I != IEnd; ++I) { + llvm::errs() << " " << I->first << " -> (" << I->second.first->FileName + << ", " << I->second.second << ")\n"; + } +} + +void ASTReader::dump() { + llvm::errs() << "*** AST File Remapping:\n"; + dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap); + dumpModuleIDOffsetMap("Global type map", GlobalTypeMap); + dumpModuleIDOffsetMap("Global declaration map", GlobalDeclMap); + dumpModuleIDOffsetMap("Global identifier map", GlobalIdentifierMap); + dumpModuleIDOffsetMap("Global selector map", GlobalSelectorMap); + dumpModuleIDOffsetMap("Global macro definition map", + GlobalMacroDefinitionMap); + dumpModuleIDOffsetMap("Global preprocessed entity map", + GlobalPreprocessedEntityMap); + } /// Return the amount of memory used by memory buffers, breaking down