diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-07-21 19:50:14 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-07-21 19:50:14 +0000 |
| commit | 204b8717d4752326654350bf4715d27fdc3de2f2 (patch) | |
| tree | 37b1f588d2c03698730a88d47c67336094025da3 /clang | |
| parent | 6853cf66d1d25e7f953574e35acef0fda1c2fa28 (diff) | |
| download | bcm5719-llvm-204b8717d4752326654350bf4715d27fdc3de2f2.tar.gz bcm5719-llvm-204b8717d4752326654350bf4715d27fdc3de2f2.zip | |
Add some debugging output to the AST reader, so we can see the global remappings we generate
llvm-svn: 135701
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Serialization/ASTReader.h | 3 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 54 |
2 files changed, 57 insertions, 0 deletions
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index ae666b717ac..d7b574a7749 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/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/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 83c894b6488..be2b79d4038 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/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<typename Key, typename PerFileData, unsigned InitialCapacity> +static void +dumpModuleIDMap(llvm::StringRef Name, + const ContinuousRangeMap<Key, PerFileData *, + InitialCapacity> &Map) { + if (Map.begin() == Map.end()) + return; + + typedef ContinuousRangeMap<Key, PerFileData *, 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->FileName + << "\n"; + } +} + +template<typename Key, typename PerFileData, typename Adjustment, + unsigned InitialCapacity> +static void +dumpModuleIDOffsetMap(llvm::StringRef Name, + const ContinuousRangeMap<Key, + std::pair<PerFileData *, + Adjustment>, + InitialCapacity> &Map) { + if (Map.begin() == Map.end()) + return; + + typedef ContinuousRangeMap<Key, std::pair<PerFileData *, Adjustment>, + 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 |

