LLVM  14.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/ArrayRef.h"
13 #include "llvm/ADT/StringSet.h"
17 
18 namespace llvm {
19 class ScopedPrinter;
20 
21 namespace codeview {
22 
23 class TypeCollection;
24 
25 /// Dumper for CodeView type streams found in COFF object files and PDB files.
27 public:
29  bool PrintRecordBytes)
30  : W(W), PrintRecordBytes(PrintRecordBytes), TpiTypes(TpiTypes) {}
31 
32  /// When dumping types from an IPI stream in a PDB, a type index may refer to
33  /// a type or an item ID. The dumper will lookup the "name" of the index in
34  /// the item database if appropriate. If ItemDB is null, it will use TypeDB,
35  /// which is correct when dumping types from an object file (/Z7).
36  void setIpiTypes(TypeCollection &Types) { IpiTypes = &Types; }
37 
38  void printTypeIndex(StringRef FieldName, TypeIndex TI) const;
39 
40  void printItemIndex(StringRef FieldName, TypeIndex TI) const;
41 
42  /// Action to take on unknown types. By default, they are ignored.
45 
46  /// Paired begin/end actions for all types. Receives all record data,
47  /// including the fixed-length record prefix.
48  Error visitTypeBegin(CVType &Record) override;
50  Error visitTypeEnd(CVType &Record) override;
53 
54 #define TYPE_RECORD(EnumName, EnumVal, Name) \
55  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
56 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
57  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
58 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
59 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
60 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
61 
62 private:
63  void printMemberAttributes(MemberAttributes Attrs);
64  void printMemberAttributes(MemberAccess Access, MethodKind Kind,
66 
67  /// Get the database of indices for the stream that we are dumping. If ItemDB
68  /// is set, then we must be dumping an item (IPI) stream. This will also
69  /// always get the appropriate DB for printing item names.
70  TypeCollection &getSourceTypes() const {
71  return IpiTypes ? *IpiTypes : TpiTypes;
72  }
73 
74  ScopedPrinter *W;
75 
76  bool PrintRecordBytes = false;
77 
78  TypeCollection &TpiTypes;
79  TypeCollection *IpiTypes = nullptr;
80 };
81 
82 } // end namespace codeview
83 } // end namespace llvm
84 
85 #endif
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::codeview::MemberAccess
MemberAccess
Source-level access specifier. (CV_access_e)
Definition: CodeView.h:263
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::codeview::TypeVisitorCallbacks
Definition: TypeVisitorCallbacks.h:18
llvm::codeview::TypeDumpVisitor
Dumper for CodeView type streams found in COFF object files and PDB files.
Definition: TypeDumpVisitor.h:26
TypeVisitorCallbacks.h
llvm::codeview::CVMemberRecord
Definition: TypeRecord.h:34
llvm::codeview::TypeDumpVisitor::visitMemberBegin
Error visitMemberBegin(CVMemberRecord &Record) override
Definition: TypeDumpVisitor.cpp:192
llvm::codeview::TypeDumpVisitor::visitTypeEnd
Error visitTypeEnd(CVType &Record) override
Definition: TypeDumpVisitor.cpp:183
llvm::codeview::TypeCollection
Definition: TypeCollection.h:18
llvm::codeview::TypeDumpVisitor::printItemIndex
void printItemIndex(StringRef FieldName, TypeIndex TI) const
Definition: TypeDumpVisitor.cpp:165
llvm::codeview::MethodKind
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Definition: CodeView.h:271
llvm::codeview::TypeDumpVisitor::visitUnknownMember
Error visitUnknownMember(CVMemberRecord &Record) override
Definition: TypeDumpVisitor.cpp:454
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:36
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::codeview::TypeDumpVisitor::visitMemberEnd
Error visitMemberEnd(CVMemberRecord &Record) override
Definition: TypeDumpVisitor.cpp:201
llvm::codeview::TypeDumpVisitor::visitUnknownType
Error visitUnknownType(CVType &Record) override
Action to take on unknown types. By default, they are ignored.
Definition: TypeDumpVisitor.cpp:459
llvm::codeview::TypeDumpVisitor::printTypeIndex
void printTypeIndex(StringRef FieldName, TypeIndex TI) const
Definition: TypeDumpVisitor.cpp:161
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
TypeRecord.h
ArrayRef.h
llvm::Record
Definition: Record.h:1472
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::codeview::CVRecord< TypeLeafKind >
StringSet.h
llvm::codeview::TypeDumpVisitor::TypeDumpVisitor
TypeDumpVisitor(TypeCollection &TpiTypes, ScopedPrinter *W, bool PrintRecordBytes)
Definition: TypeDumpVisitor.h:28
llvm::codeview::TypeDumpVisitor::visitTypeBegin
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Definition: TypeDumpVisitor.cpp:169
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::ScopedPrinter
Definition: ScopedPrinter.h:70
TypeIndex.h
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:282