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p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 /*
 27  * File:   G4FFGDebuggingMacros.hh
 28  * Author: B. Wendt (wendbryc@isu.edu)
 29  *
 30  * Created on August 17, 2012, 12:54
 31  */
 32 
 33 #ifndef G4FFGDEBUGGINGMACROS_HH
 34 #define G4FFGDEBUGGINGMACROS_HH
 35 
 36 #include "G4FFGEnumerations.hh"
 37 #include "G4FFGVerboseMacros.hh"
 38 #include "globals.hh"
 39 
 40 // Define the function as available by the compiler
 41 #if defined(__GNUC__)
 42 #  define G4FFG_FUNCTION_SIGNATURE__ G4String(__func__) + "()"
 43 #elif defined(_MSC_VER)
 44 // I'm not sure if this is the correct syntax for MS VC
 45 #  define G4FFG_FUNCTION_SIGNATURE__ G4String(__FUNCTION__) + "()"
 46 #else
 47 #  define G4FFG_FUNCTION_SIGNATURE__ "a function"
 48 #endif
 49 
 50 // Only define the variables and macros if G4DEBUG_VERBOSE is set
 51 #if defined(G4DEBUG_VERBOSE)
 52 /** G4FFGDEBUG_RECURSIVE_REPRESSION is used to aid in the repression of
 53  *  debugging messages from recursive function calls.
 54  */
 55 extern G4long G4FFGDEBUG_RECURSIVE_REPRESSION;
 56 /** G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER tracks the number of recursive
 57  *  function debugging messages were repressed.
 58  */
 59 extern G4long G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER;
 60 /** G4FFGDEBUG_DATA_STRUCTURE_REPRESSION is used to aid in the repression of
 61  *  debugging messages from functions that sort/access data elements.
 62  */
 63 extern G4long G4FFGDEBUG_DATA_STRUCTURE_REPRESSION;
 64 /** G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER tracks the number of recursive
 65  *  function debugging messages were repressed.
 66  */
 67 extern G4long G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER;
 68 
 69 // Entering functions
 70 /** G4FFG_FUNCTIONENTER__ is blank if G4DEBUG_VERBOSE is not defined at compile time.
 71  *  Otherwise, it is used by the fission fragment code to notify when a function is
 72  *  first entered.
 73  */
 74 #  define G4FFG_FUNCTIONENTER__                                                      \
 75     if ((Verbosity_ & G4FFGEnumerations::DEBUG)                                      \
 76         && !(Verbosity_ & G4FFGEnumerations::REPRESS_FUNCTION_ENTER_LEAVE_MESSAGES)) \
 77     {                                                                                \
 78       G4FFG_SPACING__                                                                \
 79       G4cout << "Entering ";                                                         \
 80       G4FFG_LOCATION__                                                               \
 81       G4cout << G4endl;                                                              \
 82     }                                                                                \
 83     G4FFG_DEPTH++;
 84 
 85 /** G4FFG_SAMPLING_FUNCTIONENTER__ wraps around G4FFG_FUNCTIONENTER__ and
 86  *  can be used in conjunctions with
 87  *  G4FFGEnumeration::REPRESS_RANDOM_SAMPLING_MESSAGES to repress debugging output
 88  *  for psuedorandom number generation functions
 89  */
 90 #  define G4FFG_SAMPLING_FUNCTIONENTER__                                       \
 91     if (!(Verbosity_ & G4FFGEnumerations::REPRESS_RANDOM_SAMPLING_MESSAGES)) { \
 92       G4FFG_FUNCTIONENTER__                                                    \
 93     }
 94 
 95 /** G4FFG_RECURSIVE_FUNCTIONENTER__ wraps around G4FFG_FUNCTIONENTER__ and
 96  *  can be used in conjunctions with
 97  *  G4FFGEnumeration::REPRESS_RECURSIVE_DEBUG_MESSAGES to repress debugging output
 98  *  recursive function calls.
 99  */
100 #  define G4FFG_RECURSIVE_FUNCTIONENTER__                                   \
101     if (Verbosity_ & G4FFGEnumerations::REPRESS_RECURSIVE_DEBUG_MESSAGES) { \
102       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                           \
103         G4FFG_FUNCTIONENTER__                                               \
104       }                                                                     \
105       else {                                                                \
106         G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER++;                          \
107       }                                                                     \
108       G4FFGDEBUG_RECURSIVE_REPRESSION++;                                    \
109     }                                                                       \
110     else {                                                                  \
111       G4FFG_FUNCTIONENTER__                                                 \
112     }
113 
114 /** G4FFG_DATA_FUNCTIONENTER__ wraps around G4FFG_FUNCTIONENTER__ and
115  *  can be used in conjunctions with
116  *  G4FFGEnumeration::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES to repress debugging output
117  *  recursive function calls.
118  */
119 #  define G4FFG_DATA_FUNCTIONENTER__                                             \
120     if (Verbosity_ & G4FFGEnumerations::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES) { \
121       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                                \
122         G4FFG_FUNCTIONENTER__                                                    \
123       }                                                                          \
124       else {                                                                     \
125         G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER++;                          \
126       }                                                                          \
127       G4FFGDEBUG_RECURSIVE_REPRESSION++;                                         \
128     }                                                                            \
129     else {                                                                       \
130       G4FFG_FUNCTIONENTER__                                                      \
131     }
132 
133 // Leaving functions
134 /** G4FFG_FUNCTIONLEAVE__ is blank if G4DEBUG_VERBOSE is not defined at compile time.
135  *  Otherwise, it is used by the fission fragment code to notify when a function is
136  *  exited. It will also be found before \p return statements, since those exit a
137  *  funtion as well.
138  */
139 #  define G4FFG_FUNCTIONLEAVE__                                                      \
140     G4FFG_DEPTH--;                                                                   \
141     if ((Verbosity_ & G4FFGEnumerations::DEBUG)                                      \
142         && !(Verbosity_ & G4FFGEnumerations::REPRESS_FUNCTION_ENTER_LEAVE_MESSAGES)) \
143     {                                                                                \
144       G4FFG_SPACING__                                                                \
145       G4cout << "Leaving ";                                                          \
146       G4FFG_LOCATION__                                                               \
147       G4cout << G4endl;                                                              \
148     }
149 
150 /** G4FFG_SAMPLING_FUNCTIONLEAVE__ wraps around G4FFG_FUNCTIONLEAVE__ and
151  *  can be used in conjunctions with
152  *  G4FFGEnumeration::REPRESS_RANDOM_SAMPLING_MESSAGES to repress debugging output
153  *  for psuedorandom number generation functions
154  */
155 #  define G4FFG_SAMPLING_FUNCTIONLEAVE__                                       \
156     if (!(Verbosity_ & G4FFGEnumerations::REPRESS_RANDOM_SAMPLING_MESSAGES)) { \
157       G4FFG_FUNCTIONLEAVE__                                                    \
158     }
159 
160 /** G4FFG_RECURSIVE_FUNCTIONLEAVE__ wraps around G4FFG_FUNCTIONLEAVE__ and
161  *  can be used in conjunctions with
162  *  G4FFGEnumeration::REPRESS_RECURSIVE_DEBUG_MESSAGES to repress debugging output
163  *  recursive function calls.
164  */
165 #  define G4FFG_RECURSIVE_FUNCTIONLEAVE__                                     \
166     if (Verbosity_ & G4FFGEnumerations::REPRESS_RECURSIVE_DEBUG_MESSAGES) {   \
167       G4FFGDEBUG_RECURSIVE_REPRESSION--;                                      \
168       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                             \
169         if (G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER > 0) {                    \
170           G4FFG_SPACING__                                                     \
171           G4cout << "==== " << G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER * 2    \
172                  << " recursive function messages suppressed ====" << G4endl; \
173           G4FFGDEBUG_RECURSIVE_REPRESSION_COUNTER = 0;                        \
174         }                                                                     \
175         G4FFG_FUNCTIONLEAVE__                                                 \
176       }                                                                       \
177     }                                                                         \
178     else {                                                                    \
179       G4FFG_FUNCTIONLEAVE__                                                   \
180     }
181 
182 /** G4FFG_DATA_FUNCTIONLEAVE__ wraps around G4FFG_FUNCTIONLEAVE__ and
183  *  can be used in conjunctions with
184  *  G4FFGEnumeration::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES to repress debugging output
185  *  recursive function calls.
186  */
187 #  define G4FFG_DATA_FUNCTIONLEAVE__                                               \
188     if (Verbosity_ & G4FFGEnumerations::REPRESS_DATA_STRUCTURE_DEBUG_MESSAGES) {   \
189       G4FFGDEBUG_RECURSIVE_REPRESSION--;                                           \
190       if (G4FFGDEBUG_RECURSIVE_REPRESSION == 0) {                                  \
191         if (G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER > 0) {                    \
192           G4FFG_SPACING__                                                          \
193           G4cout << "==== " << G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER * 2    \
194                  << " data structure function messages suppressed ====" << G4endl; \
195           G4FFGDEBUG_DATA_STRUCTURE_REPRESSION_COUNTER = 0;                        \
196         }                                                                          \
197         G4FFG_FUNCTIONLEAVE__                                                      \
198       }                                                                            \
199     }                                                                              \
200     else {                                                                         \
201       G4FFG_FUNCTIONLEAVE__                                                        \
202     }
203 #else /* G4DEBUG_VERBOSE */
204 // If G4DEBUG_VERBOSE is not defined then we will need to define these macros but leave them empty
205 // Except for G4FFG_FUNCTIONENTER__ and G4FFG_FUNCTIONLEAVE__, which will be used to track
206 // G4FFG_DEPTH
207 #  define G4FFG_FUNCTIONENTER__ G4FFG_DEPTH++;
208 #  define G4FFG_SAMPLING_FUNCTIONENTER__
209 #  define G4FFG_RECURSIVE_FUNCTIONENTER__
210 #  define G4FFG_DATA_FUNCTIONENTER__
211 #  define G4FFG_FUNCTIONLEAVE__ G4FFG_DEPTH--;
212 #  define G4FFG_SAMPLING_FUNCTIONLEAVE__
213 #  define G4FFG_RECURSIVE_FUNCTIONLEAVE__
214 #  define G4FFG_DATA_FUNCTIONLEAVE__
215 #endif /* G4DEBUG_VERBOSE */
216 
217 #endif /* G4FFGDEBUGGINGMACROS_HH */
218