LLVM  6.0.0svn
TypeDumpVisitor.h
Go to the documentation of this file.
1 //===-- TypeDumpVisitor.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_TYPEDUMPVISITOR_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
12 
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/StringSet.h"
18 
19 namespace llvm {
20 class ScopedPrinter;
21 
22 namespace codeview {
23 
24 class TypeCollection;
25 
26 /// Dumper for CodeView type streams found in COFF object files and PDB files.
28 public:
30  bool PrintRecordBytes)
31  : W(W), PrintRecordBytes(PrintRecordBytes), TpiTypes(TpiTypes) {}
32 
33  /// When dumping types from an IPI stream in a PDB, a type index may refer to
34  /// a type or an item ID. The dumper will lookup the "name" of the index in
35  /// the item database if appropriate. If ItemDB is null, it will use TypeDB,
36  /// which is correct when dumping types from an object file (/Z7).
37  void setIpiTypes(TypeCollection &Types) { IpiTypes = &Types; }
38 
39  void printTypeIndex(StringRef FieldName, TypeIndex TI) const;
40 
41  void printItemIndex(StringRef FieldName, TypeIndex TI) const;
42 
43  /// Action to take on unknown types. By default, they are ignored.
45  Error visitUnknownMember(CVMemberRecord &Record) override;
46 
47  /// Paired begin/end actions for all types. Receives all record data,
48  /// including the fixed-length record prefix.
49  Error visitTypeBegin(CVType &Record) override;
50  Error visitTypeBegin(CVType &Record, TypeIndex Index) override;
51  Error visitTypeEnd(CVType &Record) override;
52  Error visitMemberBegin(CVMemberRecord &Record) override;
53  Error visitMemberEnd(CVMemberRecord &Record) override;
54 
55 #define TYPE_RECORD(EnumName, EnumVal, Name) \
56  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
57 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
58  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
59 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
60 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
61 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
62 
63 private:
64  void printMemberAttributes(MemberAttributes Attrs);
65  void printMemberAttributes(MemberAccess Access, MethodKind Kind,
66  MethodOptions Options);
67 
68  /// Get the database of indices for the stream that we are dumping. If ItemDB
69  /// is set, then we must be dumping an item (IPI) stream. This will also
70  /// always get the appropriate DB for printing item names.
71  TypeCollection &getSourceTypes() const {
72  return IpiTypes ? *IpiTypes : TpiTypes;
73  }
74 
75  ScopedPrinter *W;
76 
77  bool PrintRecordBytes = false;
78 
79  TypeCollection &TpiTypes;
80  TypeCollection *IpiTypes = nullptr;
81 };
82 
83 } // end namespace codeview
84 } // end namespace llvm
85 
86 #endif
void printItemIndex(StringRef FieldName, TypeIndex TI) const
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Error visitTypeEnd(CVType &Record) override
void printTypeIndex(StringRef FieldName, TypeIndex TI) const
Error visitUnknownType(CVType &Record) override
Action to take on unknown types. By default, they are ignored.
TypeDumpVisitor(TypeCollection &TpiTypes, ScopedPrinter *W, bool PrintRecordBytes)
A 32-bit type reference.
Definition: TypeIndex.h:96
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Definition: CodeView.h:266
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Error visitUnknownMember(CVMemberRecord &Record) override
Error visitMemberBegin(CVMemberRecord &Record) override
MethodOptions
Equivalent to CV_fldattr_t bitfield.
Definition: CodeView.h:277
Dumper for CodeView type streams found in COFF object files and PDB files.
const unsigned Kind
void setIpiTypes(TypeCollection &Types)
When dumping types from an IPI stream in a PDB, a type index may refer to a type or an item ID...
MemberAccess
Source-level access specifier. (CV_access_e)
Definition: CodeView.h:258
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
Error visitMemberEnd(CVMemberRecord &Record) override
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49