diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-01 22:20:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-01 22:20:59 +0000 |
commit | 84b7f8d334d413c34ac7d6c6a2750d9f40e320fc (patch) | |
tree | 9fe1c3b3aab1596f798b90a1f62d5594b972faef /docs | |
parent | 556d89de5851f883d66d361d6f809d02617a7852 (diff) | |
download | external_llvm-84b7f8d334d413c34ac7d6c6a2750d9f40e320fc.zip external_llvm-84b7f8d334d413c34ac7d6c6a2750d9f40e320fc.tar.gz external_llvm-84b7f8d334d413c34ac7d6c6a2750d9f40e320fc.tar.bz2 |
Update information about the new DEBUG_TYPE macro
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7496 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r-- | docs/ProgrammersManual.html | 75 |
1 files changed, 67 insertions, 8 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 5a3ce5c..89098c2 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -24,6 +24,10 @@ <tt>dyn_cast<></tt> templates</a> <li><a href="#DEBUG">The <tt>DEBUG()</tt> macro & <tt>-debug</tt> option</a> + <ul> + <li><a href="#DEBUG_TYPE">Fine grained debug info with + <tt>DEBUG_TYPE</tt> and the <tt>-debug-only</tt> option</a/> + </ul> <li><a href="#Statistic">The <tt>Statistic</tt> template & <tt>-stats</tt> option</a> <!-- @@ -324,12 +328,11 @@ Naturally, because of this, you don't want to delete the debug printouts, but you don't want them to always be noisy. A standard compromise is to comment them out, allowing you to enable them if you need them in the future.<p> -The "<tt><a -href="/doxygen/Statistic_8h-source.html">Support/Statistic.h</a></tt>" -file provides a macro named <tt>DEBUG()</tt> that is a much nicer solution to -this problem. Basically, you can put arbitrary code into the argument of the -<tt>DEBUG</tt> macro, and it is only executed if '<tt>opt</tt>' is run with the -'<tt>-debug</tt>' command line argument: +The "<tt><a href="/doxygen/Debug_8h-source.html">Support/Debug.h</a></tt>" file +provides a macro named <tt>DEBUG()</tt> that is a much nicer solution to this +problem. Basically, you can put arbitrary code into the argument of the +<tt>DEBUG</tt> macro, and it is only executed if '<tt>opt</tt>' (or any other +tool) is run with the '<tt>-debug</tt>' command line argument: <pre> ... @@ -347,7 +350,7 @@ Then you can run your pass like this:<p> $ </pre><p> -Using the <tt>DEBUG()</tt> macro instead of a home brewed solution allows you to +Using the <tt>DEBUG()</tt> macro instead of a home-brewed solution allows you to now have to create "yet another" command line option for the debug output for your pass. Note that <tt>DEBUG()</tt> macros are disabled for optimized builds, so they do not cause a performance impact at all (for the same reason, they @@ -359,6 +362,62 @@ enable or disable it directly in gdb. Just use "<tt>set DebugFlag=0</tt>" or program hasn't been started yet, you can always just run it with <tt>-debug</tt>.<p> +<!-- _______________________________________________________________________ --> +</ul><h4><a name="DEBUG_TYPE"><hr size=0>Fine grained debug info with + <tt>DEBUG_TYPE()</tt> and the <tt>-debug-only</tt> option</a> </h4><ul> + +Sometimes you may find yourself in a situation where enabling <tt>-debug</tt> +just turns on <b>too much</b> information (such as when working on the code +generator). If you want to enable debug information with more fine-grained +control, you define the <tt>DEBUG_TYPE</tt> macro and the <tt>-debug</tt> only +option as follows:<p> + +<pre> + ... + DEBUG(std::cerr << "No debug type\n"); + #undef DEBUG_TYPE + #define DEBUG_TYPE "foo" + DEBUG(std::cerr << "'foo' debug type\n"); + #undef DEBUG_TYPE + #define DEBUG_TYPE "bar" + DEBUG(std::cerr << "'bar' debug type\n"); + #undef DEBUG_TYPE + #define DEBUG_TYPE "" + DEBUG(std::cerr << "No debug type (2)\n"); + ... +</pre><p> + +Then you can run your pass like this:<p> + +<pre> + $ opt < a.bc > /dev/null -mypass + <no output> + $ opt < a.bc > /dev/null -mypass -debug + No debug type + 'foo' debug type + 'bar' debug type + No debug type (2) + $ opt < a.bc > /dev/null -mypass -debug-only=foo + No debug type + 'foo' debug type + No debug type (2) + $ opt < a.bc > /dev/null -mypass -debug-only=bar + No debug type + 'bar' debug type + No debug type (2) + $ +</pre><p> + +Of course, in practice, you should only set <tt>DEBUG_TYPE</tt> at the top of a +file, to specify the debug type for the entire module (if you do this before you +<tt>#include "Support/Debug.h"</tt>, you don't have to insert the ugly +<tt>#undef</tt>'s). Also, you should use names more meaningful that "foo" and +"bar", because there is no system in place to ensure that names do not conflict: +if two different modules use the same string, they will all be turned on when +the name is specified. This allows all, say, instruction scheduling debug +information to be enabled with <tt>-debug-type=InstrSched</tt>, even if the +source lives in multiple files.<p> + <!-- ======================================================================= --> </ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0> @@ -1734,6 +1793,6 @@ pointer to the parent Function. <a href="mailto:sabre@nondot.org">Chris Lattner</a></address> <!-- Created: Tue Aug 6 15:00:33 CDT 2002 --> <!-- hhmts start --> -Last modified: Wed Apr 23 11:21:57 CDT 2003 +Last modified: Fri Aug 1 16:40:37 CDT 2003 <!-- hhmts end --> </font></body></html> |