blob: cdc75c1cfba0ea78ec94548985ea5fb9e1839303 [file] [log] [blame]
Zachary Turner63055452017-06-15 22:24:24 +00001//===- MinimalSymbolDumper.h ---------------------------------- *- C++ --*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Zachary Turner63055452017-06-15 22:24:24 +00006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TOOLS_LLVMPDBUTIL_MINIMAL_SYMBOL_DUMPER_H
10#define LLVM_TOOLS_LLVMPDBUTIL_MINIMAL_SYMBOL_DUMPER_H
11
12#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
13
14namespace llvm {
15namespace codeview {
16class LazyRandomTypeCollection;
17}
18
19namespace pdb {
20class LinePrinter;
Zachary Turner60478582018-01-05 19:12:40 +000021class SymbolGroup;
Zachary Turner63055452017-06-15 22:24:24 +000022
23class MinimalSymbolDumper : public codeview::SymbolVisitorCallbacks {
24public:
25 MinimalSymbolDumper(LinePrinter &P, bool RecordBytes,
Zachary Turner59e3ae82017-08-08 18:34:44 +000026 codeview::LazyRandomTypeCollection &Ids,
Zachary Turner63055452017-06-15 22:24:24 +000027 codeview::LazyRandomTypeCollection &Types)
Zachary Turnerf401e112017-08-17 20:04:31 +000028 : P(P), RecordBytes(RecordBytes), Ids(Ids), Types(Types) {}
Zachary Turner60478582018-01-05 19:12:40 +000029 MinimalSymbolDumper(LinePrinter &P, bool RecordBytes,
30 const SymbolGroup &SymGroup,
31 codeview::LazyRandomTypeCollection &Ids,
32 codeview::LazyRandomTypeCollection &Types)
33 : P(P), RecordBytes(RecordBytes), SymGroup(&SymGroup), Ids(Ids),
34 Types(Types) {}
Zachary Turner63055452017-06-15 22:24:24 +000035
36 Error visitSymbolBegin(codeview::CVSymbol &Record) override;
Zachary Turneraf8c75a2017-06-30 21:35:00 +000037 Error visitSymbolBegin(codeview::CVSymbol &Record, uint32_t Offset) override;
Zachary Turner63055452017-06-15 22:24:24 +000038 Error visitSymbolEnd(codeview::CVSymbol &Record) override;
39
Zachary Turner60478582018-01-05 19:12:40 +000040 void setSymbolGroup(const SymbolGroup *Group) { SymGroup = Group; }
41
Zachary Turner63055452017-06-15 22:24:24 +000042#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
43 virtual Error visitKnownRecord(codeview::CVSymbol &CVR, \
44 codeview::Name &Record) override;
45#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
46#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
47
48private:
Zachary Turner59e3ae82017-08-08 18:34:44 +000049 std::string typeOrIdIndex(codeview::TypeIndex TI, bool IsType) const;
50
Zachary Turner63055452017-06-15 22:24:24 +000051 std::string typeIndex(codeview::TypeIndex TI) const;
Zachary Turner59e3ae82017-08-08 18:34:44 +000052 std::string idIndex(codeview::TypeIndex TI) const;
Zachary Turner63055452017-06-15 22:24:24 +000053
54 LinePrinter &P;
Reid Klecknera6f64262018-09-11 22:00:50 +000055
56 /// Dumping certain records requires knowing what machine this is. The
57 /// S_COMPILE3 record will tell us, but if we don't see one, default to X64.
58 codeview::CPUType CompilationCPU = codeview::CPUType::X64;
59
Zachary Turnerf401e112017-08-17 20:04:31 +000060 bool RecordBytes;
Zachary Turner60478582018-01-05 19:12:40 +000061 const SymbolGroup *SymGroup = nullptr;
Zachary Turner59e3ae82017-08-08 18:34:44 +000062 codeview::LazyRandomTypeCollection &Ids;
Zachary Turner63055452017-06-15 22:24:24 +000063 codeview::LazyRandomTypeCollection &Types;
64};
65} // namespace pdb
66} // namespace llvm
67
Reid Klecknera6f64262018-09-11 22:00:50 +000068#endif