LLVM  16.0.0git
TypeDumpVisitor.h
Go to the documentation of this file.
1 //===-- TypeDumpVisitor.h - CodeView type info dumper -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
10 #define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
11 
12 #include "llvm/ADT/StringRef.h"
16 
17 namespace llvm {
18 class ScopedPrinter;
19 
20 namespace codeview {
21 class TypeIndex;
22 struct CVMemberRecord;
23 struct MemberAttributes;
24 
25 class TypeCollection;
26 
27 /// Dumper for CodeView type streams found in COFF object files and PDB files.
29 public:
31  bool PrintRecordBytes)
32  : W(W), PrintRecordBytes(PrintRecordBytes), TpiTypes(TpiTypes) {}
33 
34  /// When dumping types from an IPI stream in a PDB, a type index may refer to
35  /// a type or an item ID. The dumper will lookup the "name" of the index in
36  /// the item database if appropriate. If ItemDB is null, it will use TypeDB,
37  /// which is correct when dumping types from an object file (/Z7).
38  void setIpiTypes(TypeCollection &Types) { IpiTypes = &Types; }
39 
40  void printTypeIndex(StringRef FieldName, TypeIndex TI) const;
41 
42  void printItemIndex(StringRef FieldName, TypeIndex TI) const;
43 
44  /// Action to take on unknown types. By default, they are ignored.
47 
48  /// Paired begin/end actions for all types. Receives all record data,
49  /// including the fixed-length record prefix.
50  Error visitTypeBegin(CVType &Record) override;
52  Error visitTypeEnd(CVType &Record) override;
55 
56 #define TYPE_RECORD(EnumName, EnumVal, Name) \
57  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
58 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
59  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
60 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
61 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
62 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
63 
64 private:
65  void printMemberAttributes(MemberAttributes Attrs);
66  void printMemberAttributes(MemberAccess Access, MethodKind Kind,
68 
69  /// Get the database of indices for the stream that we are dumping. If ItemDB
70  /// is set, then we must be dumping an item (IPI) stream. This will also
71  /// always get the appropriate DB for printing item names.
72  TypeCollection &getSourceTypes() const {
73  return IpiTypes ? *IpiTypes : TpiTypes;
74  }
75 
76  ScopedPrinter *W;
77 
78  bool PrintRecordBytes = false;
79 
80  TypeCollection &TpiTypes;
81  TypeCollection *IpiTypes = nullptr;
82 };
83 
84 } // end namespace codeview
85 } // end namespace llvm
86 
87 #endif
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::codeview::MemberAccess
MemberAccess
Source-level access specifier. (CV_access_e)
Definition: CodeView.h:262
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::codeview::TypeVisitorCallbacks
Definition: TypeVisitorCallbacks.h:18
StringRef.h
llvm::codeview::TypeDumpVisitor
Dumper for CodeView type streams found in COFF object files and PDB files.
Definition: TypeDumpVisitor.h:28
TypeVisitorCallbacks.h
llvm::codeview::CVMemberRecord
Definition: TypeRecord.h:34
llvm::codeview::TypeDumpVisitor::visitMemberBegin
Error visitMemberBegin(CVMemberRecord &Record) override
Definition: TypeDumpVisitor.cpp:193
llvm::codeview::TypeDumpVisitor::visitTypeEnd
Error visitTypeEnd(CVType &Record) override
Definition: TypeDumpVisitor.cpp:184
llvm::codeview::TypeCollection
Definition: TypeCollection.h:18
llvm::codeview::TypeDumpVisitor::printItemIndex
void printItemIndex(StringRef FieldName, TypeIndex TI) const
Definition: TypeDumpVisitor.cpp:166
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::codeview::MethodKind
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Definition: CodeView.h:270
llvm::codeview::TypeDumpVisitor::visitUnknownMember
Error visitUnknownMember(CVMemberRecord &Record) override
Definition: TypeDumpVisitor.cpp:455
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::codeview::TypeDumpVisitor::setIpiTypes
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.
Definition: TypeDumpVisitor.h:38
CodeView.h
llvm::codeview::TypeDumpVisitor::visitMemberEnd
Error visitMemberEnd(CVMemberRecord &Record) override
Definition: TypeDumpVisitor.cpp:202
llvm::codeview::TypeDumpVisitor::visitUnknownType
Error visitUnknownType(CVType &Record) override
Action to take on unknown types. By default, they are ignored.
Definition: TypeDumpVisitor.cpp:460
llvm::codeview::TypeDumpVisitor::printTypeIndex
void printTypeIndex(StringRef FieldName, TypeIndex TI) const
Definition: TypeDumpVisitor.cpp:162
llvm::Record
Definition: Record.h:1573
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::codeview::CVRecord< TypeLeafKind >
llvm::codeview::TypeDumpVisitor::TypeDumpVisitor
TypeDumpVisitor(TypeCollection &TpiTypes, ScopedPrinter *W, bool PrintRecordBytes)
Definition: TypeDumpVisitor.h:30
llvm::codeview::TypeDumpVisitor::visitTypeBegin
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Definition: TypeDumpVisitor.cpp:170
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
CVRecord.h
llvm::ScopedPrinter
Definition: ScopedPrinter.h:100
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition: TypeIndex.h:96
llvm::codeview::MethodOptions
MethodOptions
Equivalent to CV_fldattr_t bitfield.
Definition: CodeView.h:281