1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDebugContext
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
12 A class for performing various debugging and memory tracing operations.
14 Full functionality (such as printing out objects currently allocated) is
15 only present in a debugging build of wxWidgets, i.e. if the __WXDEBUG__
16 symbol is defined. wxDebugContext and related functions and macros can be
17 compiled out by setting wxUSE_DEBUG_CONTEXT to 0 is setup.h
22 @see @ref overview_debugging
28 Checks the memory blocks for errors, starting from the currently set
31 @return Returns the number of errors, so a value of zero represents
32 success. Returns -1 if an error was detected that prevents
35 static int Check(bool checkAll
= false);
38 Performs a memory dump from the currently set checkpoint, writing to the
39 current debug stream. Calls the @b Dump member function for each wxObject
42 @return @true if the function succeeded, @false otherwise.
47 Returns @true if the memory allocator checks all previous memory blocks for
50 By default, this is @false since it slows down execution considerably.
52 @see SetCheckPrevious()
54 static bool GetCheckPrevious();
57 Returns @true if debug mode is on.
59 If debug mode is on, the wxObject new and delete operators store or use
60 information about memory allocation. Otherwise, a straight malloc and
61 free will be performed by these operators.
65 static bool GetDebugMode();
68 Gets the debug level (default 1).
70 The debug level is used by the wxTraceLevel function and the WXTRACELEVEL
71 macro to specify how detailed the trace information is; setting a
72 different level will only have an effect if trace statements in the
73 application specify a value other than one.
76 This is obsolete, replaced by wxLog functionality.
80 static int GetLevel();
83 Prints a list of the classes declared in this application, giving derivation
84 and whether instances of this class can be dynamically created.
86 @see PrintStatistics()
88 static bool PrintClasses();
91 Performs a statistics analysis from the currently set checkpoint, writing
92 to the current debug stream. The number of object and non-object
93 allocations is printed, together with the total size.
96 If @true, the function will also print how many objects of each class
97 have been allocated, and the space taken by these class instances.
99 @see PrintStatistics()
101 static bool PrintStatistics(bool detailed
= true);
104 Tells the memory allocator to check all previous memory blocks for errors.
105 By default, this is @false since it slows down execution considerably.
107 @see GetCheckPrevious()
109 static void SetCheckPrevious(bool check
);
112 Sets the current checkpoint: Dump and PrintStatistics operations will
113 be performed from this point on. This allows you to ignore allocations
114 that have been performed up to this point.
117 If @true, the checkpoint is reset to include all memory allocations
118 since the program started.
120 static void SetCheckpoint(bool all
= false);
123 Sets the debug mode on or off.
125 If debug mode is on, the wxObject new and delete operators store or use
126 information about memory allocation. Otherwise, a straight malloc and free
127 will be performed by these operators.
129 By default, debug mode is on if __WXDEBUG__ is defined. If the application
130 uses this function, it should make sure that all object memory allocated
131 is deallocated with the same value of debug mode. Otherwise, the delete
132 operator might try to look for memory information that does not exist.
136 static void SetDebugMode(bool debug
);
139 Sets the debug level (default 1).
141 The debug level is used by the wxTraceLevel function and the WXTRACELEVEL
142 macro to specify how detailed the trace information is; setting
143 a different level will only have an effect if trace statements in the
144 application specify a value other than one.
147 This is obsolete, replaced by wxLog functionality.
151 static void SetLevel(int level
);
154 Installs a function to be called at the end of wxWidgets shutdown.
155 It will be called after all files with global instances of
156 wxDebugContextDumpDelayCounter have run their destructors.
158 The shutdown function must be take no parameters and return nothing.
160 static void SetShutdownNotifyFunction(wxShutdownNotifyFunction func
);
165 // ============================================================================
166 // Global functions/macros
167 // ============================================================================
169 /** @addtogroup group_funcmacro_log */
173 @deprecated Use one of the wxLogTrace() functions or one of the
174 wxVLogTrace() functions instead.
176 Calls wxTrace() with printf-style variable argument syntax. Output is
177 directed to the current output stream (see wxDebugContext).
181 #define WXTRACE(format, ...)
184 @deprecated Use one of the wxLogTrace() functions or one of the
185 wxVLogTrace() functions instead.
187 Calls wxTraceLevel with printf-style variable argument syntax. Output is
188 directed to the current output stream (see wxDebugContext). The first
189 argument should be the level at which this information is appropriate. It
190 will only be output if the level returned by wxDebugContext::GetLevel is
191 equal to or greater than this value.
195 #define WXTRACELEVEL(level, format, ...)
198 @deprecated Use one of the wxLogTrace() functions or one of the
199 wxVLogTrace() functions instead.
201 Takes printf-style variable argument syntax. Output is directed to the
202 current output stream (see wxDebugContext).
206 void wxTrace(const wxString
& format
, ...);
209 @deprecated Use one of the wxLogTrace() functions or one of the
210 wxVLogTrace() functions instead.
212 Takes @e printf() style variable argument syntax. Output is directed to the
213 current output stream (see wxDebugContext). The first argument should be
214 the level at which this information is appropriate. It will only be output
215 if the level returned by wxDebugContext::GetLevel() is equal to or greater
220 void wxTraceLevel(int level
, const wxString
& format
, ...);