1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxDebugContext 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  13     A class for performing various debugging and memory tracing operations. 
  15     Full functionality (such as printing out objects currently allocated) is 
  16     only present in a debugging build of wxWidgets, i.e. if the __WXDEBUG__ 
  17     symbol is defined. wxDebugContext and related functions and macros can be 
  18     compiled out by setting wxUSE_DEBUG_CONTEXT to 0 is setup.h 
  23     @see @ref overview_debugging 
  29         Checks the memory blocks for errors, starting from the currently set 
  32         @return Returns the number of errors, so a value of zero represents 
  33                 success. Returns -1 if an error was detected that prevents 
  36     static int Check(bool checkAll 
= false); 
  39         Performs a memory dump from the currently set checkpoint, writing to the 
  40         current debug stream. Calls the @b Dump member function for each wxObject 
  43         @return @true if the function succeeded, @false otherwise. 
  48         Returns @true if the memory allocator checks all previous memory blocks for 
  51         By default, this is @false since it slows down execution considerably. 
  53         @see SetCheckPrevious() 
  55     static bool GetCheckPrevious(); 
  58         Returns @true if debug mode is on. 
  60         If debug mode is on, the wxObject new and delete operators store or use 
  61         information about memory allocation. Otherwise, a straight malloc and 
  62         free will be performed by these operators. 
  66     static bool GetDebugMode(); 
  69         Gets the debug level (default 1). 
  71         The debug level is used by the wxTraceLevel function and the WXTRACELEVEL 
  72         macro to specify how detailed the trace information is; setting a 
  73         different level will only have an effect if trace statements in the 
  74         application specify a value other than one. 
  77         This is obsolete, replaced by wxLog functionality. 
  81     static int GetLevel(); 
  84         Prints a list of the classes declared in this application, giving derivation 
  85         and whether instances of this class can be dynamically created. 
  87         @see PrintStatistics() 
  89     static bool PrintClasses(); 
  92         Performs a statistics analysis from the currently set checkpoint, writing 
  93         to the current debug stream. The number of object and non-object 
  94         allocations is printed, together with the total size. 
  97             If @true, the function will also print how many objects of each class 
  98             have been allocated, and the space taken by these class instances. 
 100         @see PrintStatistics() 
 102     static bool PrintStatistics(bool detailed 
= true); 
 105         Tells the memory allocator to check all previous memory blocks for errors. 
 106         By default, this is @false since it slows down execution considerably. 
 108         @see GetCheckPrevious() 
 110     static void SetCheckPrevious(bool check
); 
 113         Sets the current checkpoint: Dump and PrintStatistics operations will 
 114         be performed from this point on. This allows you to ignore allocations 
 115         that have been performed up to this point. 
 118             If @true, the checkpoint is reset to include all memory allocations 
 119             since the program started. 
 121     static void SetCheckpoint(bool all 
= false); 
 124         Sets the debug mode on or off. 
 126         If debug mode is on, the wxObject new and delete operators store or use 
 127         information about memory allocation. Otherwise, a straight malloc and free 
 128         will be performed by these operators. 
 130         By default, debug mode is on if __WXDEBUG__ is defined. If the application 
 131         uses this function, it should make sure that all object memory allocated 
 132         is deallocated with the same value of debug mode. Otherwise, the delete 
 133         operator might try to look for memory information that does not exist. 
 137     static void SetDebugMode(bool debug
); 
 140         Sets the debug level (default 1). 
 142         The debug level is used by the wxTraceLevel function and the WXTRACELEVEL 
 143         macro to specify how detailed the trace information is; setting 
 144         a different level will only have an effect if trace statements in the 
 145         application specify a value other than one. 
 148         This is obsolete, replaced by wxLog functionality. 
 152     static void SetLevel(int level
); 
 155         Installs a function to be called at the end of wxWidgets shutdown. 
 156         It will be called after all files with global instances of 
 157         wxDebugContextDumpDelayCounter have run their destructors. 
 159         The shutdown function must be take no parameters and return nothing. 
 161     static void SetShutdownNotifyFunction(wxShutdownNotifyFunction func
); 
 166 // ============================================================================ 
 167 // Global functions/macros 
 168 // ============================================================================ 
 170 /** @ingroup group_funcmacro_log */ 
 174     @deprecated Use one of the wxLogTrace() functions or one of the 
 175                 wxVLogTrace() functions instead. 
 177     Calls wxTrace() with printf-style variable argument syntax. Output is 
 178     directed to the current output stream (see wxDebugContext). 
 182 #define WXTRACE(format, ...) 
 185     @deprecated Use one of the wxLogTrace() functions or one of the 
 186                 wxVLogTrace() functions instead. 
 188     Calls wxTraceLevel with printf-style variable argument syntax. Output is 
 189     directed to the current output stream (see wxDebugContext). The first 
 190     argument should be the level at which this information is appropriate. It 
 191     will only be output if the level returned by wxDebugContext::GetLevel is 
 192     equal to or greater than this value. 
 196 #define WXTRACELEVEL(level, format, ...) 
 199     @deprecated Use one of the wxLogTrace() functions or one of the 
 200                 wxVLogTrace() functions instead. 
 202     Takes printf-style variable argument syntax. Output is directed to the 
 203     current output stream (see wxDebugContext). 
 207 void wxTrace(const wxString
& format
, ...); 
 210     @deprecated Use one of the wxLogTrace() functions or one of the 
 211                 wxVLogTrace() functions instead. 
 213     Takes @e printf() style variable argument syntax. Output is directed to the 
 214     current output stream (see wxDebugContext). The first argument should be 
 215     the level at which this information is appropriate. It will only be output 
 216     if the level returned by wxDebugContext::GetLevel() is equal to or greater 
 221 void wxTraceLevel(int level
, const wxString
& format
, ...);