aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/Debug.cpp')
-rw-r--r--llvm/lib/Support/Debug.cpp73
1 files changed, 21 insertions, 52 deletions
diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp
index b48045c..19b40ab 100644
--- a/llvm/lib/Support/Debug.cpp
+++ b/llvm/lib/Support/Debug.cpp
@@ -30,8 +30,6 @@
#include "llvm/Support/circular_raw_ostream.h"
#include "llvm/Support/raw_ostream.h"
-#include "DebugOptions.h"
-
#undef isCurrentDebugType
#undef setCurrentDebugType
#undef setCurrentDebugTypes
@@ -81,32 +79,21 @@ void setCurrentDebugTypes(const char **Types, unsigned Count) {
// All Debug.h functionality is a no-op in NDEBUG mode.
#ifndef NDEBUG
-namespace {
-struct CreateDebug {
- static void *call() {
- return new cl::opt<bool, true>("debug", cl::desc("Enable debug output"),
- cl::Hidden, cl::location(DebugFlag));
- }
-};
+// -debug - Command line option to enable the DEBUG statements in the passes.
+// This flag may only be enabled in debug builds.
+static cl::opt<bool, true>
+Debug("debug", cl::desc("Enable debug output"), cl::Hidden,
+ cl::location(DebugFlag));
// -debug-buffer-size - Buffer the last N characters of debug output
//until program termination.
-struct CreateDebugBufferSize {
- static void *call() {
- return new cl::opt<unsigned>(
- "debug-buffer-size",
- cl::desc("Buffer the last N characters of debug output "
- "until program termination. "
- "[default 0 -- immediate print-out]"),
- cl::Hidden, cl::init(0));
- }
-};
-} // namespace
-
-// -debug - Command line option to enable the DEBUG statements in the passes.
-// This flag may only be enabled in debug builds.
-static ManagedStatic<cl::opt<bool, true>, CreateDebug> Debug;
-static ManagedStatic<cl::opt<unsigned>, CreateDebugBufferSize> DebugBufferSize;
+static cl::opt<unsigned>
+DebugBufferSize("debug-buffer-size",
+ cl::desc("Buffer the last N characters of debug output "
+ "until program termination. "
+ "[default 0 -- immediate print-out]"),
+ cl::Hidden,
+ cl::init(0));
namespace {
@@ -121,33 +108,15 @@ struct DebugOnlyOpt {
CurrentDebugType->push_back(std::string(dbgType));
}
};
-} // namespace
-static DebugOnlyOpt DebugOnlyOptLoc;
-
-namespace {
-struct CreateDebugOnly {
- static void *call() {
- return new cl::opt<DebugOnlyOpt, true, cl::parser<std::string>>(
- "debug-only",
- cl::desc("Enable a specific type of debug output (comma separated list "
- "of types)"),
- cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"),
- cl::location(DebugOnlyOptLoc), cl::ValueRequired);
- }
-};
} // namespace
-static ManagedStatic<cl::opt<DebugOnlyOpt, true, cl::parser<std::string>>,
- CreateDebugOnly>
- DebugOnly;
-
-void llvm::initDebugOptions() {
- *Debug;
- *DebugBufferSize;
- *DebugOnly;
-}
+static DebugOnlyOpt DebugOnlyOptLoc;
+static cl::opt<DebugOnlyOpt, true, cl::parser<std::string> >
+DebugOnly("debug-only", cl::desc("Enable a specific type of debug output (comma separated list of types)"),
+ cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"),
+ cl::location(DebugOnlyOptLoc), cl::ValueRequired);
// Signal handlers - dump debug output on termination.
static void debug_user_sig_handler(void *Cookie) {
// This is a bit sneaky. Since this is under #ifndef NDEBUG, we
@@ -165,10 +134,10 @@ raw_ostream &llvm::dbgs() {
static struct dbgstream {
circular_raw_ostream strm;
- dbgstream()
- : strm(errs(), "*** Debug Log Output ***\n",
- (!EnableDebugBuffering || !DebugFlag) ? 0 : *DebugBufferSize) {
- if (EnableDebugBuffering && DebugFlag && *DebugBufferSize != 0)
+ dbgstream() :
+ strm(errs(), "*** Debug Log Output ***\n",
+ (!EnableDebugBuffering || !DebugFlag) ? 0 : DebugBufferSize) {
+ 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, nullptr);