diff options
author | Zachary Turner <zturner@google.com> | 2017-04-10 06:14:09 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-04-10 06:14:09 +0000 |
commit | 1b1a70f1725804fc1cd9cc490576791e01b01223 (patch) | |
tree | b72cb3cb9d87ff84658ff8c7b4d6561776923ef0 /llvm/lib/DebugInfo/PDB/PDBSymbol.cpp | |
parent | 34888c08bc72813f959ce8f3bee85d313bebcf69 (diff) | |
download | bcm5719-llvm-1b1a70f1725804fc1cd9cc490576791e01b01223.tar.gz bcm5719-llvm-1b1a70f1725804fc1cd9cc490576791e01b01223.zip |
General usability improvements to generic PDB library.
1. Added some asserts to make sure concrete symbol types don't
get constructed with RawSymbols that have an incompatible
SymTag enum value.
2. Added new forwarding macros that auto-define an Id/Sym method
pair whenever there is a method that returns a SymIndexId.
Previously we would just provide one method that returned only
the SymIndexId and it was up to the caller to use the Session
object to get a pointer to the symbol. Now we automatically
get both the method that returns the Id, as well as a method
that returns the pointer directly with just one macro.
3. Added some methods for dumping straight to stdout that can
be used from inside the debugger for diagnostics during a
debug session.
4. Added a clone() method and a cast<T>() method to PDBSymbol
that can shorten some usage patterns.
llvm-svn: 299831
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/PDBSymbol.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/PDBSymbol.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp index 633e11aacf1..2c8438f9c23 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp @@ -10,6 +10,7 @@ #include "llvm/DebugInfo/PDB/PDBSymbol.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" +#include "llvm/DebugInfo/PDB/IPDBSession.h" #include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h" #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h" @@ -100,7 +101,7 @@ PDBSymbol::create(const IPDBSession &PDBSession, } #define TRY_DUMP_TYPE(Type) \ - if (const Type *DerivedThis = dyn_cast<Type>(this)) \ + if (const Type *DerivedThis = this->cast<Type>()) \ Dumper.dump(OS, Indent, *DerivedThis); #define ELSE_TRY_DUMP_TYPE(Type, Dumper) else TRY_DUMP_TYPE(Type, Dumper) @@ -109,6 +110,26 @@ void PDBSymbol::defaultDump(raw_ostream &OS, int Indent) const { RawSymbol->dump(OS, Indent); } +void PDBSymbol::dumpProperties() const { + outs() << "\n"; + defaultDump(outs(), 0); + outs().flush(); +} + +void PDBSymbol::dumpChildStats() const { + TagStats Stats; + getChildStats(Stats); + outs() << "\n"; + for (auto &Stat : Stats) { + outs() << Stat.first << ": " << Stat.second << "\n"; + } + outs().flush(); +} + +std::unique_ptr<PDBSymbol> PDBSymbol::clone() const { + return Session.getSymbolById(getSymIndexId()); +} + PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); } uint32_t PDBSymbol::getSymIndexId() const { return RawSymbol->getSymIndexId(); } @@ -148,3 +169,7 @@ PDBSymbol::getChildStats(TagStats &Stats) const { Result->reset(); return Result; } + +std::unique_ptr<PDBSymbol> PDBSymbol::getSymbolByIdHelper(uint32_t Id) const { + return Session.getSymbolById(Id); +} |