diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -2542,3 +2542,37 @@ llvm::cl::ParseCommandLineOptions(argc, argv, StringRef(Overview), &llvm::nulls()); } + +// All Debug.h functionality is a no-op in NDEBUG mode. +#ifndef NDEBUG + +namespace llvm { +extern ManagedStatic> CurrentDebugType; +} + +extern unsigned DebugBufferSize; + +// -debug - Command line option to enable the DEBUG statements in the passes. +// This flag may only be enabled in debug builds. +static cl::opt 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. +static cl::opt + DebugBufferSizeOpt("debug-buffer-size", + cl::desc("Buffer the last N characters of debug output " + "until program termination. " + "[default 0 -- immediate print-out]"), + cl::Hidden, + cl::location(DebugBufferSize)); + +static cl::list>> + 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(CurrentDebugType), cl::CommaSeparated, + cl::callback([](const std::string &) { DebugFlag = true; })); + +#endif diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp --- a/llvm/lib/Support/Debug.cpp +++ b/llvm/lib/Support/Debug.cpp @@ -42,7 +42,7 @@ /// Exported boolean set by the -debug option. bool DebugFlag = false; -static ManagedStatic> CurrentDebugType; +ManagedStatic> CurrentDebugType; /// Return true if the specified string is the debug type /// specified on the command line, or if none was specified on the command line @@ -79,29 +79,7 @@ // All Debug.h functionality is a no-op in NDEBUG mode. #ifndef NDEBUG -// -debug - Command line option to enable the DEBUG statements in the passes. -// This flag may only be enabled in debug builds. -static cl::opt -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. -static cl::opt -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)); - -static cl::list>> - 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(CurrentDebugType), cl::CommaSeparated, - cl::callback([](const std::string &) { DebugFlag = true; })); +unsigned DebugBufferSize = 0; // Signal handlers - dump debug output on termination. static void debug_user_sig_handler(void *Cookie) {