OSDN Git Service

Implement user selection of traceable features at run-time.
[mingw/mingw-get.git] / src / debug.h
1 #ifndef DEBUG_H
2 /*
3  * debug.h
4  *
5  * $Id$
6  *
7  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8  * Copyright (C) 2010, 2011, MinGW Project
9  *
10  *
11  * Hooks to facilitate conditional compilation of code to activate
12  * selective debugging features.
13  *
14  *
15  * This is free software.  Permission is granted to copy, modify and
16  * redistribute this software, under the provisions of the GNU General
17  * Public License, Version 3, (or, at your option, any later version),
18  * as published by the Free Software Foundation; see the file COPYING
19  * for licensing details.
20  *
21  * Note, in particular, that this software is provided "as is", in the
22  * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23  * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24  * PARTICULAR PURPOSE.  Under no circumstances will the author, or the
25  * MinGW Project, accept liability for any damages, however caused,
26  * arising from the use of this software.
27  *
28  */
29 # define DEBUG_H  1
30
31  /* To facilitate identification of code which is added to assist
32   * in debugging, we explicitly define the DEBUG_INVOKED symbol; this
33   * explicitly expands to nothing, so that it may be incorporated
34   * as a transparent marker on any line of such code.
35   */
36 # define DEBUG_INVOKED
37
38 # if DEBUGLEVEL
39   /* Here, we provide definitions and declarations which allow us
40    * to selectively enable compilation of (any specific class of)
41    * debug specific code.
42    */
43 #  define DEBUG_ENABLED(FEATURE)    (DEBUGLEVEL & (FEATURE))
44
45 #  define DEBUG_TRACE_DYNAMIC                   0x0001
46
47 #  if DEBUG_ENABLED( DEBUG_TRACE_DYNAMIC )
48    /* When compiled with dynamic tracing enabled, we allow the user
49     * to choose which features are to be traced, by specification of
50     * the "--trace=FEATURES" command line option; however the features
51     * which may be selected are restricted to an explicit subset which
52     * has been specified at compile time.
53     */
54 #   include "pkgopts.h"
55
56 #   define DEBUG_REQUEST_FLAGS       pkgOptions()->GetValue( OPTION_DEBUGLEVEL )
57 #   define DEBUG_REQUEST(OPTION)    (DEBUG_ENABLED( OPTION ) & DEBUG_REQUEST_FLAGS)
58
59 #  else  /* ! DEBUG_TRACE_DYNAMIC */
60    /* Without dynamic tracing enabled, only those features selected
61     * at compile time may be traced, and all unconditionally.
62     */
63 #   define DEBUG_REQUEST(OPTION)    (DEBUGLEVEL & (OPTION))
64 #  endif
65
66 #  define DEBUG_TRACE_INIT                      0x0010
67 #  define DEBUG_TRACE_TRANSACTIONS              0x0020
68 #  define DEBUG_SUPPRESS_INSTALLATION           0x0040
69 #  define DEBUG_UPDATE_INVENTORY                0x0080
70
71 #  define DEBUG_TRACE_INTERNET_REQUESTS         0x0100
72
73 #  define DEBUG_INHIBIT_RITES_OF_PASSAGE        0x7000
74 #  define DEBUG_FAIL_FILE_RENAME_RITE           0x1000
75 #  define DEBUG_FAIL_FILE_UNLINK_RITE           0x2000
76
77 #  define DEBUG_INVOKE_IF( TEST, ACTION )       if( TEST ) ACTION
78
79 # else /* DEBUGLEVEL == 0 */
80   /* We use this space to provide any declarations which may be
81    * necessary to disable compilation of debug specific code...
82    */
83 #  define DEBUG_INVOKE_IF( TEST, ACTION )       /* DO NOTHING */
84
85 # endif /* DEBUGLEVEL */
86
87 #endif /* DEBUG_H: $RCSfile$: end of file */