X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FDebug.cpp;h=824654257acc4fa93399feb15e8ced89ae47a931;hb=dbe68adeb2d329ff3b3b522a80aab13af10c9460;hp=0c0f15eddd3014ecc78f439037cc1767f7b92694;hpb=d04a8d4b33ff316ca4cf961e06c9e312eff8e64f;p=oota-llvm.git diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index 0c0f15eddd3..824654257ac 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Signals.h" #include "llvm/Support/circular_raw_ostream.h" +#include "llvm/Support/ManagedStatic.h" using namespace llvm; @@ -44,20 +45,20 @@ Debug("debug", cl::desc("Enable debug output"), cl::Hidden, //until program termination. static cl::opt DebugBufferSize("debug-buffer-size", - cl::desc("Buffer the last N characters of debug output" + cl::desc("Buffer the last N characters of debug output " "until program termination. " "[default 0 -- immediate print-out]"), cl::Hidden, cl::init(0)); -static std::string CurrentDebugType; +static ManagedStatic CurrentDebugType; namespace { struct DebugOnlyOpt { void operator=(const std::string &Val) const { DebugFlag |= !Val.empty(); - CurrentDebugType = Val; + *CurrentDebugType = Val; } }; @@ -86,7 +87,7 @@ static void debug_user_sig_handler(void *Cookie) { // with the -debug-only=X option. // bool llvm::isCurrentDebugType(const char *DebugType) { - return CurrentDebugType.empty() || DebugType == CurrentDebugType; + return CurrentDebugType->empty() || DebugType == *CurrentDebugType; } /// setCurrentDebugType - Set the current debug type, as if the -debug-only=X @@ -94,7 +95,7 @@ bool llvm::isCurrentDebugType(const char *DebugType) { /// debug output to be produced. /// void llvm::setCurrentDebugType(const char *Type) { - CurrentDebugType = Type; + *CurrentDebugType = Type; } /// dbgs - Return a circular-buffered debug stream. @@ -109,7 +110,7 @@ raw_ostream &llvm::dbgs() { if (EnableDebugBuffering && DebugFlag && DebugBufferSize != 0) // TODO: Add a handler for SIGUSER1-type signals so the user can // force a debug dump. - sys::AddSignalHandler(&debug_user_sig_handler, 0); + sys::AddSignalHandler(&debug_user_sig_handler, nullptr); // Otherwise we've already set the debug stream buffer size to // zero, disabling buffering so it will output directly to errs(). }