1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDebugStreamBuf
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxDebugStreamBuf
12 This class allows you to treat debugging output in a similar
13 (stream-based) fashion on different platforms. Under
14 Windows, an ostream constructed with this buffer outputs
15 to the debugger, or other program that intercepts debugging
16 output. On other platforms, the output goes to standard error (cerr).
18 This is soon to be obsolete, replaced by wxLog functionality.
25 class wxDebugStreamBuf
36 A class for performing various debugging and memory tracing
37 operations. Full functionality (such as printing out objects
38 currently allocated) is only present in a debugging build of wxWidgets,
39 i.e. if the __WXDEBUG__ symbol is defined. wxDebugContext
40 and related functions and macros can be compiled out by setting
41 wxUSE_DEBUG_CONTEXT to 0 is setup.h
52 Checks the memory blocks for errors, starting from the currently set
55 @return Returns the number of errors, so a value of zero represents
56 success. Returns -1 if an error was detected that
57 prevents further checking.
62 Performs a memory dump from the currently set checkpoint, writing to the
63 current debug stream. Calls the @b Dump member function for each wxObject
66 @return @true if the function succeeded, @false otherwise.
71 Returns @true if the memory allocator checks all previous memory blocks for
73 By default, this is @false since it slows down execution considerably.
75 @see SetCheckPrevious()
77 bool GetCheckPrevious();
80 Returns @true if debug mode is on. If debug mode is on, the wxObject new and
82 operators store or use information about memory allocation. Otherwise,
83 a straight malloc and free will be performed by these operators.
90 Gets the debug level (default 1). The debug level is used by the wxTraceLevel
92 the WXTRACELEVEL macro to specify how detailed the trace information is; setting
93 a different level will only have an effect if trace statements in the
95 specify a value other than one.
96 This is obsolete, replaced by wxLog functionality.
103 Returns the output stream associated with the debug context.
104 This is obsolete, replaced by wxLog functionality.
111 Returns a pointer to the output stream buffer associated with the debug context.
112 There may not necessarily be a stream buffer if the stream has been set
114 This is obsolete, replaced by wxLog functionality.
116 streambuf
* GetStreamBuf();
119 Returns @true if there is a stream currently associated
120 with the debug context.
121 This is obsolete, replaced by wxLog functionality.
123 @see SetStream(), GetStream()
128 Prints a list of the classes declared in this application, giving derivation
129 and whether instances of this class can be dynamically created.
131 @see PrintStatistics()
136 Performs a statistics analysis from the currently set checkpoint, writing
137 to the current debug stream. The number of object and non-object
138 allocations is printed, together with the total size.
141 If @true, the function will also print how many
142 objects of each class have been allocated, and the space taken by
143 these class instances.
145 @see PrintStatistics()
147 bool PrintStatistics(bool detailed
= true);
150 Tells the memory allocator to check all previous memory blocks for errors.
151 By default, this is @false since it slows down execution considerably.
153 @see GetCheckPrevious()
155 void SetCheckPrevious(bool check
);
158 Sets the current checkpoint: Dump and PrintStatistics operations will
159 be performed from this point on. This allows you to ignore allocations
160 that have been performed up to this point.
163 If @true, the checkpoint is reset to include all
164 memory allocations since the program started.
166 void SetCheckpoint(bool all
= false);
169 Sets the debug mode on or off. If debug mode is on, the wxObject new and delete
170 operators store or use information about memory allocation. Otherwise,
171 a straight malloc and free will be performed by these operators.
172 By default, debug mode is on if __WXDEBUG__ is defined. If the application
173 uses this function, it should make sure that all object memory allocated
174 is deallocated with the same value of debug mode. Otherwise, the
175 delete operator might try to look for memory information that does not
180 void SetDebugMode(bool debug
);
183 Sets the current debug file and creates a stream. This will delete any existing
184 stream and stream buffer. By default, the debug context stream
185 outputs to the debugger (Windows) or standard error (other platforms).
187 bool SetFile(const wxString
& filename
);
190 Sets the debug level (default 1). The debug level is used by the wxTraceLevel
192 the WXTRACELEVEL macro to specify how detailed the trace information is; setting
193 a different level will only have an effect if trace statements in the
195 specify a value other than one.
196 This is obsolete, replaced by wxLog functionality.
200 void SetLevel(int level
);
203 Installs a function to be called at the end of wxWidgets shutdown. It will be
205 all files with global instances of wxDebugContextDumpDelayCounter have run
207 The shutdown function must be take no parameters and return nothing.
209 void SetShutdownNotifyFunction(wxShutdownNotifyFunction func
);
212 Sets the debugging stream to be the debugger (Windows) or standard error (other
214 This is the default setting. The existing stream will be flushed and deleted.
215 This is obsolete, replaced by wxLog functionality.
217 bool SetStandardError();
220 Sets the stream and optionally, stream buffer associated with the debug context.
221 This operation flushes and deletes the existing stream (and stream buffer if
223 This is obsolete, replaced by wxLog functionality.
226 Stream to associate with the debug context. Do not set this to @NULL.
228 Stream buffer to associate with the debug context.
230 void SetStream(ostream
* stream
, streambuf
* streamBuf
= NULL
);
235 // ============================================================================
236 // Global functions/macros
237 // ============================================================================
239 /** @ingroup group_funcmacro_log */
243 @deprecated Use one of the wxLogTrace() functions or one of the
244 wxVLogTrace() functions instead.
246 Calls wxTrace() with printf-style variable argument syntax. Output is
247 directed to the current output stream (see wxDebugContext).
251 #define WXTRACE(format, ...)
254 @deprecated Use one of the wxLogTrace() functions or one of the
255 wxVLogTrace() functions instead.
257 Calls wxTraceLevel with printf-style variable argument syntax. Output is
258 directed to the current output stream (see wxDebugContext). The first
259 argument should be the level at which this information is appropriate. It
260 will only be output if the level returned by wxDebugContext::GetLevel is
261 equal to or greater than this value.
265 #define WXTRACELEVEL(level, format, ...)
268 @deprecated Use one of the wxLogTrace() functions or one of the
269 wxVLogTrace() functions instead.
271 Takes printf-style variable argument syntax. Output is directed to the
272 current output stream (see wxDebugContext).
276 void wxTrace(const wxString
& format
, ...);
279 @deprecated Use one of the wxLogTrace() functions or one of the
280 wxVLogTrace() functions instead.
282 Takes @e printf() style variable argument syntax. Output is directed to the
283 current output stream (see wxDebugContext). The first argument should be
284 the level at which this information is appropriate. It will only be output
285 if the level returned by wxDebugContext::GetLevel() is equal to or greater
290 void wxTraceLevel(int level
, const wxString
& format
, ...);