1 //===-- TypeDumpVisitor.h - CodeView type info dumper -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
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"
25 /// Dumper for CodeView type streams found in COFF object files and PDB files.
26 class TypeDumpVisitor : public TypeVisitorCallbacks {
28 TypeDumpVisitor(TypeDatabase &TypeDB, ScopedPrinter *W, bool PrintRecordBytes)
29 : W(W), PrintRecordBytes(PrintRecordBytes), TypeDB(TypeDB) {}
31 /// When dumping types from an IPI stream in a PDB, a type index may refer to
32 /// a type or an item ID. The dumper will lookup the "name" of the index in
33 /// the item database if appropriate. If ItemDB is null, it will use TypeDB,
34 /// which is correct when dumping types from an object file (/Z7).
35 void setItemDB(TypeDatabase &DB) { ItemDB = &DB; }
37 void printTypeIndex(StringRef FieldName, TypeIndex TI) const;
39 void printItemIndex(StringRef FieldName, TypeIndex TI) const;
41 /// Action to take on unknown types. By default, they are ignored.
42 Error visitUnknownType(CVType &Record) override;
43 Error visitUnknownMember(CVMemberRecord &Record) override;
45 /// Paired begin/end actions for all types. Receives all record data,
46 /// including the fixed-length record prefix.
47 Error visitTypeBegin(CVType &Record) override;
48 Error visitTypeEnd(CVType &Record) override;
49 Error visitMemberBegin(CVMemberRecord &Record) override;
50 Error visitMemberEnd(CVMemberRecord &Record) override;
52 #define TYPE_RECORD(EnumName, EnumVal, Name) \
53 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
54 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
55 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
56 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
57 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
58 #include "TypeRecords.def"
61 void printMemberAttributes(MemberAttributes Attrs);
62 void printMemberAttributes(MemberAccess Access, MethodKind Kind,
63 MethodOptions Options);
65 /// Get the database of indices for the stream that we are dumping. If ItemDB
66 /// is set, then we must be dumping an item (IPI) stream. This will also
67 /// always get the appropriate DB for printing item names.
68 TypeDatabase &getSourceDB() const { return ItemDB ? *ItemDB : TypeDB; }
72 bool PrintRecordBytes = false;
75 TypeDatabase *ItemDB = nullptr;
78 } // end namespace codeview
79 } // end namespace llvm