blob: d832a48b12653cd94b5a8d5007c49c0b193e5f4b [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- SymbolDumper.h - CodeView symbol info dumper ------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H
10#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/StringSet.h"
14#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
15#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
16#include "llvm/DebugInfo/CodeView/TypeIndex.h"
17
18namespace llvm {
19class ScopedPrinter;
20
21namespace codeview {
22class TypeCollection;
23
24/// Dumper for CodeView symbol streams found in COFF object files and PDB files.
25class CVSymbolDumper {
26public:
27 CVSymbolDumper(ScopedPrinter &W, TypeCollection &Types,
28 CodeViewContainer Container,
Andrew Scull0372a572018-11-16 15:47:06 +000029 std::unique_ptr<SymbolDumpDelegate> ObjDelegate, CPUType CPU,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010030 bool PrintRecordBytes)
31 : W(W), Types(Types), Container(Container),
Andrew Scull0372a572018-11-16 15:47:06 +000032 ObjDelegate(std::move(ObjDelegate)), CompilationCPUType(CPU),
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010033 PrintRecordBytes(PrintRecordBytes) {}
34
35 /// Dumps one type record. Returns false if there was a type parsing error,
36 /// and true otherwise. This should be called in order, since the dumper
37 /// maintains state about previous records which are necessary for cross
38 /// type references.
39 Error dump(CVRecord<SymbolKind> &Record);
40
41 /// Dumps the type records in Data. Returns false if there was a type stream
42 /// parse error, and true otherwise.
43 Error dump(const CVSymbolArray &Symbols);
44
Andrew Scull0372a572018-11-16 15:47:06 +000045 CPUType getCompilationCPUType() const { return CompilationCPUType; }
46
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010047private:
48 ScopedPrinter &W;
49 TypeCollection &Types;
50 CodeViewContainer Container;
51 std::unique_ptr<SymbolDumpDelegate> ObjDelegate;
Andrew Scull0372a572018-11-16 15:47:06 +000052 CPUType CompilationCPUType;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010053 bool PrintRecordBytes;
54};
55} // end namespace codeview
56} // end namespace llvm
57
58#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLDUMPER_H