[llvm] r222547 - Allow multiple -debug-only args
Matthias Braun
matze at braunis.de
Fri Nov 21 10:06:10 PST 2014
Author: matze
Date: Fri Nov 21 12:06:09 2014
New Revision: 222547
URL: http://llvm.org/viewvc/llvm-project?rev=222547&view=rev
Log:
Allow multiple -debug-only args
Debug output is shown if any of the -debug-only arguments match.
Modified:
llvm/trunk/lib/Support/Debug.cpp
Modified: llvm/trunk/lib/Support/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Debug.cpp?rev=222547&r1=222546&r2=222547&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Debug.cpp (original)
+++ llvm/trunk/lib/Support/Debug.cpp Fri Nov 21 12:06:09 2014
@@ -51,14 +51,16 @@ DebugBufferSize("debug-buffer-size",
cl::Hidden,
cl::init(0));
-static ManagedStatic<std::string> CurrentDebugType;
+static ManagedStatic<std::vector<std::string> > CurrentDebugType;
namespace {
struct DebugOnlyOpt {
void operator=(const std::string &Val) const {
- DebugFlag |= !Val.empty();
- *CurrentDebugType = Val;
+ if (Val.empty())
+ return;
+ DebugFlag = true;
+ CurrentDebugType->push_back(Val);
}
};
@@ -68,7 +70,7 @@ static DebugOnlyOpt DebugOnlyOptLoc;
static cl::opt<DebugOnlyOpt, true, cl::parser<std::string> >
DebugOnly("debug-only", cl::desc("Enable a specific type of debug output"),
- cl::Hidden, cl::value_desc("debug string"),
+ cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"),
cl::location(DebugOnlyOptLoc), cl::ValueRequired);
// Signal handlers - dump debug output on termination.
@@ -87,7 +89,15 @@ static void debug_user_sig_handler(void
// with the -debug-only=X option.
//
bool llvm::isCurrentDebugType(const char *DebugType) {
- return CurrentDebugType->empty() || DebugType == *CurrentDebugType;
+ if (CurrentDebugType->empty())
+ return true;
+ // see if DebugType is in list. Note: do not use find() as that forces us to
+ // unnecessarily create an std::string instance.
+ for (auto d : *CurrentDebugType) {
+ if (d == DebugType)
+ return true;
+ }
+ return false;
}
/// setCurrentDebugType - Set the current debug type, as if the -debug-only=X
@@ -95,7 +105,8 @@ bool llvm::isCurrentDebugType(const char
/// debug output to be produced.
///
void llvm::setCurrentDebugType(const char *Type) {
- *CurrentDebugType = Type;
+ CurrentDebugType->clear();
+ CurrentDebugType->push_back(Type);
}
/// dbgs - Return a circular-buffered debug stream.
More information about the llvm-commits
mailing list