1 //===-- SymbolDumper.h - CodeView symbol 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_SYMBOLDUMPER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H
11 
12 #include "llvm/DebugInfo/CodeView/CVRecord.h"
13 #include "llvm/DebugInfo/CodeView/CodeView.h"
14 #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
15 #include "llvm/Support/Error.h"
16 
17 #include <memory>
18 #include <utility>
19 
20 namespace llvm {
21 class ScopedPrinter;
22 
23 namespace codeview {
24 class TypeCollection;
25 
26 /// Dumper for CodeView symbol streams found in COFF object files and PDB files.
27 class CVSymbolDumper {
28 public:
29   CVSymbolDumper(ScopedPrinter &W, TypeCollection &Types,
30                  CodeViewContainer Container,
31                  std::unique_ptr<SymbolDumpDelegate> ObjDelegate, CPUType CPU,
32                  bool PrintRecordBytes)
33       : W(W), Types(Types), Container(Container),
34         ObjDelegate(std::move(ObjDelegate)), CompilationCPUType(CPU),
35         PrintRecordBytes(PrintRecordBytes) {}
36 
37   /// Dumps one type record.  Returns false if there was a type parsing error,
38   /// and true otherwise.  This should be called in order, since the dumper
39   /// maintains state about previous records which are necessary for cross
40   /// type references.
41   Error dump(CVRecord<SymbolKind> &Record);
42 
43   /// Dumps the type records in Data. Returns false if there was a type stream
44   /// parse error, and true otherwise.
45   Error dump(const CVSymbolArray &Symbols);
46 
47   CPUType getCompilationCPUType() const { return CompilationCPUType; }
48 
49 private:
50   ScopedPrinter &W;
51   TypeCollection &Types;
52   CodeViewContainer Container;
53   std::unique_ptr<SymbolDumpDelegate> ObjDelegate;
54   CPUType CompilationCPUType;
55   bool PrintRecordBytes;
56 };
57 } // end namespace codeview
58 } // end namespace llvm
59 
60 #endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H
61