LLVM 24.0.0git
LinePrinter.h
Go to the documentation of this file.
1//===- LinePrinter.h ------------------------------------------ *- 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_PDB_NATIVE_LINEPRINTER_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_LINEPRINTER_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/ADT/Twine.h"
19#include "llvm/Support/Regex.h"
21
22#include <list>
23
24// Container for filter options to control which elements will be printed.
26 std::list<std::string> ExcludeTypes;
27 std::list<std::string> ExcludeSymbols;
28 std::list<std::string> ExcludeCompilands;
29 std::list<std::string> IncludeTypes;
30 std::list<std::string> IncludeSymbols;
31 std::list<std::string> IncludeCompilands;
34 std::optional<uint32_t> DumpModi;
35 std::optional<uint32_t> ParentRecurseDepth;
36 std::optional<uint32_t> ChildrenRecurseDepth;
37 std::optional<uint32_t> SymbolOffset;
39};
40
41namespace llvm {
42namespace msf {
43class MSFStreamLayout;
44} // namespace msf
45namespace pdb {
46
47class ClassLayout;
48class PDBFile;
49class SymbolGroup;
50class WithColor;
51
53 friend class pdb::WithColor;
54
55public:
56 LLVM_ABI LinePrinter(int Indent, bool UseColor, raw_ostream &Stream,
57 const FilterOptions &Filters);
58
59 LLVM_ABI void Indent(uint32_t Amount = 0);
60 LLVM_ABI void Unindent(uint32_t Amount = 0);
61 LLVM_ABI void NewLine();
62
63 LLVM_ABI void printLine(const Twine &T);
64 LLVM_ABI void print(const Twine &T);
65 template <typename... Ts> void formatLine(const char *Fmt, Ts &&...Items) {
66 printLine(formatv(Fmt, std::forward<Ts>(Items)...));
67 }
68 template <typename... Ts> void format(const char *Fmt, Ts &&...Items) {
69 print(formatv(Fmt, std::forward<Ts>(Items)...));
70 }
71
73 uint64_t StartOffset);
75 uint64_t BaseAddr, uint64_t StartOffset);
76
78 uint32_t StreamIdx, StringRef StreamPurpose,
81 const msf::MSFStreamLayout &Stream,
82 BinarySubstreamRef Substream);
84 const msf::MSFStreamLayout &Stream);
85
86 bool hasColor() const { return UseColor; }
87 raw_ostream &getStream() { return OS; }
88 int getIndentLevel() const { return CurrentIndent; }
89
94
95 const FilterOptions &getFilters() const { return Filters; }
96
97private:
98 template <typename Iter>
99 void SetFilters(std::list<Regex> &List, Iter Begin, Iter End) {
100 List.clear();
101 for (; Begin != End; ++Begin)
102 List.emplace_back(StringRef(*Begin));
103 }
104
105 raw_ostream &OS;
106 int IndentSpaces;
107 int CurrentIndent;
108 bool UseColor;
109 const FilterOptions &Filters;
110
111 std::list<Regex> ExcludeCompilandFilters;
112 std::list<Regex> ExcludeTypeFilters;
113 std::list<Regex> ExcludeSymbolFilters;
114
115 std::list<Regex> IncludeCompilandFilters;
116 std::list<Regex> IncludeTypeFilters;
117 std::list<Regex> IncludeSymbolFilters;
118};
119
130
132 return PrintScope{Scope, W};
133}
134
137 : L(&L), Amount(Amount) {
138 L.Indent(Amount);
139 }
140 explicit AutoIndent(const PrintScope &Scope) {
141 L = &Scope.P;
142 Amount = Scope.IndentLevel;
143 }
145 if (L)
146 L->Unindent(Amount);
147 }
148
149 LinePrinter *L = nullptr;
151};
152
153template <class T>
155 return Printer.getStream() << Item;
156}
157
172
174public:
177
178 raw_ostream &get() { return OS; }
179
180private:
181 void applyColor(PDB_ColorItem C);
182 raw_ostream &OS;
183 bool UseColor;
184};
185} // namespace pdb
186} // namespace llvm
187
188#endif
amdgpu next use AMDGPU Next Use Analysis Printer
#define LLVM_ABI
Definition Compiler.h:215
#define T
#define P(N)
static ManagedStatic< cl::opt< cl::boolOrDefault >, CreateUseColor > UseColor
Definition WithColor.cpp:33
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
Describes the layout of a stream in an MSF layout.
Definition MSFCommon.h:78
bool hasColor() const
Definition LinePrinter.h:86
LLVM_ABI void print(const Twine &T)
void format(const char *Fmt, Ts &&...Items)
Definition LinePrinter.h:68
LLVM_ABI void printLine(const Twine &T)
const FilterOptions & getFilters() const
Definition LinePrinter.h:95
LLVM_ABI void Unindent(uint32_t Amount=0)
LLVM_ABI void NewLine()
LLVM_ABI void formatMsfStreamData(StringRef Label, PDBFile &File, uint32_t StreamIdx, StringRef StreamPurpose, uint64_t Offset, uint64_t Size)
int getIndentLevel() const
Definition LinePrinter.h:88
LLVM_ABI bool IsSymbolExcluded(llvm::StringRef SymbolName)
raw_ostream & getStream()
Definition LinePrinter.h:87
LLVM_ABI LinePrinter(int Indent, bool UseColor, raw_ostream &Stream, const FilterOptions &Filters)
LLVM_ABI void formatMsfStreamBlocks(PDBFile &File, const msf::MSFStreamLayout &Stream)
void formatLine(const char *Fmt, Ts &&...Items)
Definition LinePrinter.h:65
LLVM_ABI void formatBinary(StringRef Label, ArrayRef< uint8_t > Data, uint64_t StartOffset)
LLVM_ABI bool IsTypeExcluded(llvm::StringRef TypeName, uint64_t Size)
LLVM_ABI bool IsClassExcluded(const ClassLayout &Class)
LLVM_ABI bool IsCompilandExcluded(llvm::StringRef CompilandName)
LLVM_ABI void Indent(uint32_t Amount=0)
raw_ostream & get()
LLVM_ABI WithColor(LinePrinter &P, PDB_ColorItem C)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
PrintScope withLabelWidth(const PrintScope &Scope, uint32_t W)
raw_ostream & operator<<(LinePrinter &Printer, const T &Item)
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
@ Other
Any other memory.
Definition ModRef.h:68
std::list< std::string > IncludeCompilands
Definition LinePrinter.h:31
std::optional< uint32_t > DumpModi
Definition LinePrinter.h:34
std::list< std::string > IncludeTypes
Definition LinePrinter.h:29
std::list< std::string > IncludeSymbols
Definition LinePrinter.h:30
uint32_t SizeThreshold
Definition LinePrinter.h:33
std::list< std::string > ExcludeTypes
Definition LinePrinter.h:26
std::optional< uint32_t > SymbolOffset
Definition LinePrinter.h:37
std::optional< uint32_t > ChildrenRecurseDepth
Definition LinePrinter.h:36
uint32_t PaddingThreshold
Definition LinePrinter.h:32
std::list< std::string > ExcludeCompilands
Definition LinePrinter.h:28
std::optional< uint32_t > ParentRecurseDepth
Definition LinePrinter.h:35
std::list< std::string > ExcludeSymbols
Definition LinePrinter.h:27
AutoIndent(const PrintScope &Scope)
AutoIndent(LinePrinter &L, uint32_t Amount=0)
PrintScope(const PrintScope &Other, uint32_t LabelWidth)
PrintScope(LinePrinter &P, uint32_t IndentLevel)