1 //===-- CVTypeDumper.h - CodeView type info dumper --------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_DEBUGINFO_CODEVIEW_CVTYPEDUMPER_H 11 #define LLVM_DEBUGINFO_CODEVIEW_CVTYPEDUMPER_H 12 13 #include "llvm/ADT/ArrayRef.h" 14 #include "llvm/ADT/StringSet.h" 15 #include "llvm/DebugInfo/CodeView/TypeDatabase.h" 16 #include "llvm/DebugInfo/CodeView/TypeIndex.h" 17 #include "llvm/DebugInfo/CodeView/TypeRecord.h" 18 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" 19 #include "llvm/Support/ScopedPrinter.h" 20 21 namespace llvm { 22 23 namespace codeview { 24 25 class TypeServerHandler; 26 27 /// Dumper for CodeView type streams found in COFF object files and PDB files. 28 class CVTypeDumper { 29 public: 30 explicit CVTypeDumper(TypeDatabase &TypeDB, 31 TypeServerHandler *Handler = nullptr) 32 : TypeDB(TypeDB), Handler(Handler) {} 33 34 /// Dumps one type record. Returns false if there was a type parsing error, 35 /// and true otherwise. This should be called in order, since the dumper 36 /// maintains state about previous records which are necessary for cross 37 /// type references. 38 Error dump(const CVType &Record, TypeVisitorCallbacks &Dumper); 39 40 /// Dumps the type records in Types. Returns false if there was a type stream 41 /// parse error, and true otherwise. 42 Error dump(const CVTypeArray &Types, TypeVisitorCallbacks &Dumper); 43 44 /// Dumps the type records in Data. Returns false if there was a type stream 45 /// parse error, and true otherwise. Use this method instead of the 46 /// CVTypeArray overload when type records are laid out contiguously in 47 /// memory. 48 Error dump(ArrayRef<uint8_t> Data, TypeVisitorCallbacks &Dumper); 49 50 static void printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, 51 TypeIndex TI, TypeDatabase &DB); 52 53 private: 54 TypeDatabase &TypeDB; 55 TypeServerHandler *Handler; 56 }; 57 58 } // end namespace codeview 59 } // end namespace llvm 60 61 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPER_H 62