summaryrefslogtreecommitdiff
path: root/include/llvm/Support/Debug.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-28 15:32:19 +0000
committerChris Lattner <sabre@nondot.org>2009-10-28 15:32:19 +0000
commit70197a3a0413476801622484b9c83cf6f2d6f82c (patch)
tree7b47449a0d64d0783adac61eb2a0c4a6aa764d97 /include/llvm/Support/Debug.h
parent1507cd03a64679f6999f51218a3a0180d51ab673 (diff)
downloadllvm-70197a3a0413476801622484b9c83cf6f2d6f82c.tar.gz
llvm-70197a3a0413476801622484b9c83cf6f2d6f82c.tar.bz2
llvm-70197a3a0413476801622484b9c83cf6f2d6f82c.tar.xz
add a new 'SetCurrentDebugType' API (requested by Andrew Haley for JIT
stuff) to programmatically control the current debug flavor. While I'm at it, doxygenate Debug.h and clean it up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/Debug.h')
-rw-r--r--include/llvm/Support/Debug.h67
1 files changed, 35 insertions, 32 deletions
diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h
index 6f82ea716f..afa828c369 100644
--- a/include/llvm/Support/Debug.h
+++ b/include/llvm/Support/Debug.h
@@ -28,39 +28,47 @@
namespace llvm {
-// DebugFlag - This boolean is set to true if the '-debug' command line option
-// is specified. This should probably not be referenced directly, instead, use
-// the DEBUG macro below.
-//
-#ifndef NDEBUG
-extern bool DebugFlag;
+/// DEBUG_TYPE macro - Files can specify a DEBUG_TYPE as a string, which causes
+/// all of their DEBUG statements to be activatable with -debug-only=thatstring.
+#ifndef DEBUG_TYPE
+#define DEBUG_TYPE ""
#endif
-
-// isCurrentDebugType - Return true if the specified string is the debug type
-// specified on the command line, or if none was specified on the command line
-// with the -debug-only=X option.
-//
+
#ifndef NDEBUG
+/// DebugFlag - This boolean is set to true if the '-debug' command line option
+/// is specified. This should probably not be referenced directly, instead, use
+/// the DEBUG macro below.
+///
+extern bool DebugFlag;
+
+/// isCurrentDebugType - Return true if the specified string is the debug type
+/// specified on the command line, or if none was specified on the command line
+/// with the -debug-only=X option.
+///
bool isCurrentDebugType(const char *Type);
-#else
-#define isCurrentDebugType(X) (false)
-#endif
-
-// DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug
-// information. In the '-debug' option is specified on the commandline, and if
-// this is a debug build, then the code specified as the option to the macro
-// will be executed. Otherwise it will not be. Example:
-//
-// DEBUG_WITH_TYPE("bitset", errs() << "Bitset contains: " << Bitset << "\n");
-//
-// This will emit the debug information if -debug is present, and -debug-only is
-// not specified, or is specified as "bitset".
-#ifdef NDEBUG
-#define DEBUG_WITH_TYPE(TYPE, X) do { } while (0)
-#else
+/// SetCurrentDebugType - Set the current debug type, as if the -debug-only=X
+/// option were specified. Note that DebugFlag also needs to be set to true for
+/// debug output to be produced.
+///
+void SetCurrentDebugType(const char *Type);
+
+/// DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug
+/// information. In the '-debug' option is specified on the commandline, and if
+/// this is a debug build, then the code specified as the option to the macro
+/// will be executed. Otherwise it will not be. Example:
+///
+/// DEBUG_WITH_TYPE("bitset", errs() << "Bitset contains: " << Bitset << "\n");
+///
+/// This will emit the debug information if -debug is present, and -debug-only
+/// is not specified, or is specified as "bitset".
#define DEBUG_WITH_TYPE(TYPE, X) \
do { if (DebugFlag && isCurrentDebugType(TYPE)) { X; } } while (0)
+
+#else
+#define isCurrentDebugType(X) (false)
+#define SetCurrentDebugType(X)
+#define DEBUG_WITH_TYPE(TYPE, X) do { } while (0)
#endif
// DEBUG macro - This macro should be used by passes to emit debug information.
@@ -70,11 +78,6 @@ bool isCurrentDebugType(const char *Type);
//
// DEBUG(errs() << "Bitset contains: " << Bitset << "\n");
//
-
-#ifndef DEBUG_TYPE
-#define DEBUG_TYPE ""
-#endif
-
#define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X)
} // End llvm namespace