1 //===- LinePrinter.h ------------------------------------------ *- C++ --*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
11 #define LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/ADT/Twine.h"
16 #include "llvm/Support/BinaryStreamRef.h"
17 #include "llvm/Support/FormatVariadic.h"
18 #include "llvm/Support/Regex.h"
19 #include "llvm/Support/raw_ostream.h"
24 class BinaryStreamReader;
26 class MSFStreamLayout;
34 friend class WithColor;
37 LinePrinter(int Indent, bool UseColor, raw_ostream &Stream);
39 void Indent(uint32_t Amount = 0);
40 void Unindent(uint32_t Amount = 0);
43 void printLine(const Twine &T);
44 void print(const Twine &T);
45 template <typename... Ts> void formatLine(const char *Fmt, Ts &&... Items) {
46 printLine(formatv(Fmt, std::forward<Ts>(Items)...));
48 template <typename... Ts> void format(const char *Fmt, Ts &&... Items) {
49 print(formatv(Fmt, std::forward<Ts>(Items)...));
52 void formatBinary(StringRef Label, ArrayRef<uint8_t> Data,
53 uint32_t StartOffset);
54 void formatBinary(StringRef Label, ArrayRef<uint8_t> Data, uint64_t BaseAddr,
55 uint32_t StartOffset);
57 void formatMsfStreamData(StringRef Label, PDBFile &File, uint32_t StreamIdx,
58 StringRef StreamPurpose, uint32_t Offset,
60 void formatMsfStreamData(StringRef Label, PDBFile &File,
61 const msf::MSFStreamLayout &Stream,
62 BinarySubstreamRef Substream);
64 bool hasColor() const { return UseColor; }
65 raw_ostream &getStream() { return OS; }
66 int getIndentLevel() const { return CurrentIndent; }
68 bool IsClassExcluded(const ClassLayout &Class);
69 bool IsTypeExcluded(llvm::StringRef TypeName, uint32_t Size);
70 bool IsSymbolExcluded(llvm::StringRef SymbolName);
71 bool IsCompilandExcluded(llvm::StringRef CompilandName);
74 template <typename Iter>
75 void SetFilters(std::list<Regex> &List, Iter Begin, Iter End) {
77 for (; Begin != End; ++Begin)
78 List.emplace_back(StringRef(*Begin));
86 std::list<Regex> ExcludeCompilandFilters;
87 std::list<Regex> ExcludeTypeFilters;
88 std::list<Regex> ExcludeSymbolFilters;
90 std::list<Regex> IncludeCompilandFilters;
91 std::list<Regex> IncludeTypeFilters;
92 std::list<Regex> IncludeSymbolFilters;
96 explicit AutoIndent(LinePrinter &L, uint32_t Amount = 0)
97 : L(L), Amount(Amount) {
100 ~AutoIndent() { L.Unindent(Amount); }
107 inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
108 Printer.getStream() << Item;
109 return Printer.getStream();
112 enum class PDB_ColorItem {
129 WithColor(LinePrinter &P, PDB_ColorItem C);
132 raw_ostream &get() { return OS; }
135 void applyColor(PDB_ColorItem C);