33 std::list<llvm::Regex> &IncludeFilters,
34 std::list<llvm::Regex> &ExcludeFilters) {
38 auto match_pred = [Item](
llvm::Regex &
R) {
return R.match(Item); };
42 if (!IncludeFilters.empty() && !
any_of(IncludeFilters, match_pred))
45 if (
any_of(ExcludeFilters, match_pred))
56 : OS(Stream), IndentSpaces(
Indent), CurrentIndent(0), UseColor(UseColor),
58 SetFilters(ExcludeTypeFilters, Filters.ExcludeTypes.begin(),
59 Filters.ExcludeTypes.end());
60 SetFilters(ExcludeSymbolFilters, Filters.ExcludeSymbols.begin(),
61 Filters.ExcludeSymbols.end());
62 SetFilters(ExcludeCompilandFilters, Filters.ExcludeCompilands.begin(),
63 Filters.ExcludeCompilands.end());
65 SetFilters(IncludeTypeFilters, Filters.IncludeTypes.begin(),
66 Filters.IncludeTypes.end());
67 SetFilters(IncludeSymbolFilters, Filters.IncludeSymbols.begin(),
68 Filters.IncludeSymbols.end());
69 SetFilters(IncludeCompilandFilters, Filters.IncludeCompilands.begin(),
70 Filters.IncludeCompilands.end());
75 Amount = IndentSpaces;
76 CurrentIndent += Amount;
81 Amount = IndentSpaces;
82 CurrentIndent = std::max<int>(0, CurrentIndent - Amount);
87 OS.indent(CurrentIndent);
100 if (
Class.deepPaddingSize() < Filters.PaddingThreshold)
106 uint64_t StartOffset) {
112 CurrentIndent + IndentSpaces,
true);
119 uint64_t
Base, uint64_t StartOffset) {
126 CurrentIndent + IndentSpaces,
true);
137 uint64_t ByteLen = 0;
143 std::vector<Run> Runs;
151 Runs.emplace_back(CurrentBlock);
152 while (!Blocks.
empty()) {
153 Run *CurrentRun = &Runs.back();
155 if (NextBlock < CurrentBlock || (NextBlock - CurrentBlock > 1)) {
156 Runs.emplace_back(NextBlock);
157 CurrentRun = &Runs.back();
161 CurrentRun->ByteLen += Used;
162 StreamBytesRemaining -= Used;
163 CurrentBlock = NextBlock;
170 for (
const auto &R : Runs) {
172 return std::make_pair(R,
Offset);
182 if (StreamIdx >= File.getNumStreams()) {
183 formatLine(
"Stream {0}: Not present", StreamIdx);
186 if (
Size +
Offset > File.getStreamByteSize(StreamIdx)) {
188 "Stream {0}: Invalid offset and size, range out of stream bounds",
193 auto S = File.createIndexedStream(StreamIdx);
196 formatLine(
"Stream {0}: Not present", StreamIdx);
201 (
Size == 0) ? S->getLength() : std::min(
Offset +
Size, S->getLength());
204 formatLine(
"Stream {0}: {1} (dumping {2:N} / {3:N} bytes)", StreamIdx,
205 StreamPurpose,
Size, S->getLength());
212 auto Layout = File.getStreamLayout(StreamIdx);
230 std::tie(FoundRun, RunOffset) =
findRun(Substream.
Offset, Runs);
231 assert(FoundRun.ByteLen >= RunOffset);
232 uint64_t Len = FoundRun.ByteLen - RunOffset;
234 uint64_t
Base = FoundRun.Block * File.getBlockSize() + RunOffset;
238 CurrentIndent + IndentSpaces,
true);
253 uint64_t L = StreamLayout.
Length;
260 std::min(L,
static_cast<uint64_t
>(File.getBlockSize()));
262 cantFail(File.getBlockData(Blocks.front(), File.getBlockSize()));
263 uint64_t BaseOffset = Blocks.front();
264 BaseOffset *= File.getBlockSize();
266 CurrentIndent + IndentSpaces,
true);
271 Blocks = Blocks.drop_front();
276 if (IsItemExcluded(TypeName, IncludeTypeFilters, ExcludeTypeFilters))
278 if (
Size < Filters.SizeThreshold)
284 return IsItemExcluded(SymbolName, IncludeSymbolFilters, ExcludeSymbolFilters);
288 return IsItemExcluded(CompilandName, IncludeCompilandFilters,
289 ExcludeCompilandFilters);
293 : OS(
P.OS), UseColor(
P.hasColor()) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static std::pair< Run, uint64_t > findRun(uint64_t Offset, ArrayRef< Run > Runs)
static std::vector< Run > computeBlockRuns(uint32_t BlockSize, const msf::MSFStreamLayout &Layout)
static const int BlockSize
Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
const T & front() const
Get the first element.
bool empty() const
Check if the array is empty.
Provides read only access to a subclass of BinaryStream.
LLVM_ABI Error readBytes(ArrayRef< uint8_t > &Buffer, uint32_t Size)
Read Size bytes from the underlying stream at the current offset and and set Buffer to the resulting ...
uint64_t bytesRemaining() const
RefType drop_front(uint64_t N) const
Return a new BinaryStreamRef with the first N elements removed.
RefType keep_front(uint64_t N) const
Return a new BinaryStreamRef with only the first N elements remaining.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Describes the layout of a stream in an MSF layout.
std::vector< support::ulittle32_t > Blocks
LLVM_ABI void print(const Twine &T)
LLVM_ABI void printLine(const Twine &T)
LLVM_ABI void Unindent(uint32_t Amount=0)
LLVM_ABI void formatMsfStreamData(StringRef Label, PDBFile &File, uint32_t StreamIdx, StringRef StreamPurpose, uint64_t Offset, uint64_t Size)
LLVM_ABI bool IsSymbolExcluded(llvm::StringRef SymbolName)
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)
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)
LLVM_ABI WithColor(LinePrinter &P, PDB_ColorItem C)
This class implements an extremely fast bulk output stream that can only output to a stream.
virtual raw_ostream & changeColor(enum Colors Color, bool Bold=false, bool BG=false)
Changes the foreground color of text that will be output from this point forward.
virtual raw_ostream & resetColor()
Resets the colors to terminal defaults.
static constexpr Colors GREEN
static constexpr Colors RED
static constexpr Colors MAGENTA
static constexpr Colors YELLOW
static constexpr Colors CYAN
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
FormattedBytes format_bytes_with_ascii(ArrayRef< uint8_t > Bytes, std::optional< uint64_t > FirstByteOffset=std::nullopt, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
ArrayRef(const T &OneElt) -> ArrayRef< T >
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')
void consumeError(Error Err)
Consume a Error without doing anything.
BinaryStreamRef StreamData