13 class DebugCounterList :
public cl::list<std::string, DebugCounter> {
18 template <
class... Mods>
19 explicit DebugCounterList(Mods &&... Ms) :
Base(std::forward<Mods>(Ms)...) {}
22 void printOptionInfo(
size_t GlobalWidth)
const override {
30 outs() <<
" -" << ArgStr;
33 Option::printHelpStr(HelpStr, GlobalWidth, ArgStr.size() + 6);
35 for (
auto Name : CounterInstance) {
37 CounterInstance.getCounterInfo(CounterInstance.getCounterId(
Name));
38 size_t NumSpaces = GlobalWidth - Info.first.size() - 8;
39 outs() <<
" =" << Info.first;
40 outs().
indent(NumSpaces) <<
" - " << Info.second <<
'\n';
49 cl::desc(
"Comma separated list of debug counter skip and count"),
63 if (CounterPair.second.empty()) {
64 errs() <<
"DebugCounter Error: " << Val <<
" does not have an = in it\n";
70 if (CounterPair.second.getAsInteger(0, CounterVal)) {
71 errs() <<
"DebugCounter Error: " << CounterPair.second
72 <<
" is not a number\n";
77 if (CounterPair.first.endswith(
"-skip")) {
78 auto CounterName = CounterPair.first.drop_back(5);
79 unsigned CounterID = RegisteredCounters.
idFor(CounterName);
81 errs() <<
"DebugCounter Error: " << CounterName
82 <<
" is not a registered counter\n";
86 auto Res = Counters.
insert({CounterID, {0, -1}});
87 Res.first->second.first = CounterVal;
88 }
else if (CounterPair.first.endswith(
"-count")) {
89 auto CounterName = CounterPair.first.drop_back(6);
90 unsigned CounterID = RegisteredCounters.
idFor(CounterName);
92 errs() <<
"DebugCounter Error: " << CounterName
93 <<
" is not a registered counter\n";
97 auto Res = Counters.
insert({CounterID, {0, -1}});
98 Res.first->second.second = CounterVal;
100 errs() <<
"DebugCounter Error: " << CounterPair.first
101 <<
" does not end with -skip or -count\n";
106 OS <<
"Counters and values:\n";
107 for (
const auto &KV : Counters)
108 OS <<
left_justify(RegisteredCounters[KV.first], 32) <<
": {"
109 << KV.second.first <<
"," << KV.second.second <<
"}\n";
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
static DebugCounter & instance()
Returns a reference to the singleton instance.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static ManagedStatic< DebugCounter > DC
LLVM_DUMP_METHOD void dump() const
void print(raw_ostream &OS) const
This file provides an implementation of debug counters.
unsigned idFor(const T &Entry) const
idFor - return the ID for an existing entry.
static DebugCounterList DebugCounterOption("debug-counter", cl::desc("Comma separated list of debug counter skip and count"), cl::CommaSeparated, cl::ZeroOrMore, cl::location(DebugCounter::instance()))
raw_ostream & outs()
This returns a reference to a raw_ostream for standard output.
This file declares helper objects for defining debug options that can be configured via the command l...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
void push_back(const std::string &)
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
LocationClass< Ty > location(Ty &L)