llvm/tools/llvm-pdbdump/LinePrinter.h
Zachary Turner e98c913509 [llvm-pdbdump] Display padding bytes on record layout
When dumping classes, show where padding occurs, and at the end of the
class print statistics about how many bytes total of padding exist in a
class.

Since PDB doesn't specifically contain information about padding, we have
to mimic this by sort of reversing a small portion of the record layout
algorithm (e.g. looking at offsets and sizes and trying to determine
whether something is part of the same field or a new field).

Differential Revision: https://reviews.llvm.org/D31800

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299869 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 19:33:29 +00:00

100 lines
2.1 KiB
C++

//===- LinePrinter.h ------------------------------------------ *- C++ --*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
#define LLVM_TOOLS_LLVMPDBDUMP_LINEPRINTER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Regex.h"
#include <list>
namespace llvm {
namespace pdb {
class LinePrinter {
friend class WithColor;
public:
LinePrinter(int Indent, bool UseColor, raw_ostream &Stream);
void Indent();
void Unindent();
void NewLine();
bool hasColor() const { return UseColor; }
raw_ostream &getStream() { return OS; }
int getIndentLevel() const { return CurrentIndent; }
bool IsTypeExcluded(llvm::StringRef TypeName);
bool IsSymbolExcluded(llvm::StringRef SymbolName);
bool IsCompilandExcluded(llvm::StringRef CompilandName);
private:
template <typename Iter>
void SetFilters(std::list<Regex> &List, Iter Begin, Iter End) {
List.clear();
for (; Begin != End; ++Begin)
List.emplace_back(StringRef(*Begin));
}
raw_ostream &OS;
int IndentSpaces;
int CurrentIndent;
bool UseColor;
std::list<Regex> ExcludeCompilandFilters;
std::list<Regex> ExcludeTypeFilters;
std::list<Regex> ExcludeSymbolFilters;
std::list<Regex> IncludeCompilandFilters;
std::list<Regex> IncludeTypeFilters;
std::list<Regex> IncludeSymbolFilters;
};
template <class T>
inline raw_ostream &operator<<(LinePrinter &Printer, const T &Item) {
Printer.getStream() << Item;
return Printer.getStream();
}
enum class PDB_ColorItem {
None,
Address,
Type,
Comment,
Padding,
Keyword,
Offset,
Identifier,
Path,
SectionHeader,
LiteralValue,
Register,
};
class WithColor {
public:
WithColor(LinePrinter &P, PDB_ColorItem C);
~WithColor();
raw_ostream &get() { return OS; }
private:
void applyColor(PDB_ColorItem C);
raw_ostream &OS;
bool UseColor;
};
}
}
#endif