1 \section{\class{wxDebugContext
}}\label{wxdebugcontext
}
3 A class for performing various debugging and memory tracing
4 operations. Full functionality (such as printing out objects
5 currently allocated) is only present in a debugging build of wxWindows,
6 i.e. if the DEBUG symbol is defined and non-zero. wxDebugContext
7 and related functions and macros can be compiled out by setting
8 USE
\_DEBUG\_CONTEXT to
0 is wx
\_setup.h
10 \wxheading{Derived from
}
16 \overview{Overview
}{wxdebugcontextoverview
}
18 \latexignore{\rtfignore{\wxheading{Members
}}}
20 \membersection{wxDebugContext::Check
}\label{wxdebugcontextcheck
}
22 \func{int
}{Check
}{\void}
24 Checks the memory blocks for errors, starting from the currently set
27 \wxheading{Return value
}
29 Returns the number of errors,
30 so a value of zero represents success. Returns -
1 if an error
31 was detected that prevents further checking.
33 \membersection{wxDebugContext::Dump
}\label{wxdebugcontextdump
}
35 \func{bool
}{Dump
}{\void}
37 Performs a memory dump from the currently set checkpoint, writing to the
38 current debug stream. Calls the
{\bf Dump
} member function for each wxObject
41 \wxheading{Return value
}
43 TRUE if the function succeeded, FALSE otherwise.
45 \membersection{wxDebugContext::GetCheckPrevious
}\label{wxdebugcontextgetcheckprevious
}
47 \func{bool
}{GetCheckPrevious
}{\void}
49 Returns TRUE if the memory allocator checks all previous memory blocks for errors.
50 By default, this is FALSE since it slows down execution considerably.
54 \helpref{wxDebugContext::SetCheckPrevious
}{wxdebugcontextsetcheckprevious
}
56 \membersection{wxDebugContext::GetDebugMode
}\label{wxdebugcontextgetdebugmode
}
58 \func{bool
}{GetDebugMode
}{\void}
60 Returns TRUE if debug mode is on. If debug mode is on, the wxObject new and delete
61 operators store or use information about memory allocation. Otherwise,
62 a straight malloc and free will be performed by these operators.
66 \helpref{wxDebugContext::SetDebugMode
}{wxdebugcontextsetdebugmode
}
68 \membersection{wxDebugContext::GetLevel
}\label{wxdebugcontextgetlevel
}
70 \func{int
}{GetLevel
}{\void}
72 Gets the debug level (default
1). The debug level is used by the wxTraceLevel function and
73 the WXTRACELEVEL macro to specify how detailed the trace information is; setting
74 a different level will only have an effect if trace statements in the application
75 specify a value other than one.
77 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
81 \helpref{wxDebugContext::SetLevel
}{wxdebugcontextsetlevel
}
83 \membersection{wxDebugContext::GetStream
}\label{wxdebugcontextgetstream
}
85 \func{ostream\&
}{GetStream
}{\void}
87 Returns the output stream associated with the debug context.
89 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
93 \helpref{wxDebugContext::SetStream
}{wxdebugcontextsetstream
}
95 \membersection{wxDebugContext::GetStreamBuf
}\label{wxdebugcontextgetstreambuf
}
97 \func{streambuf*
}{GetStreamBuf
}{\void}
99 Returns a pointer to the output stream buffer associated with the debug context.
100 There may not necessarily be a stream buffer if the stream has been set
103 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
105 \membersection{wxDebugContext::HasStream
}\label{wxdebugcontexthasstream
}
107 \func{bool
}{HasStream
}{\void}
109 Returns TRUE if there is a stream currently associated
110 with the debug context.
112 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
116 \helpref{wxDebugContext::SetStream
}{wxdebugcontextsetstream
},
\helpref{wxDebugContext::GetStream
}{wxdebugcontextgetstream
}
118 \membersection{wxDebugContext::PrintClasses
}\label{wxdebugcontextprintclasses
}
120 \func{bool
}{PrintClasses
}{\void}
122 Prints a list of the classes declared in this application, giving derivation
123 and whether instances of this class can be dynamically created.
127 \helpref{wxDebugContext::PrintStatistics
}{wxdebugcontextprintstatistics
}
129 \membersection{wxDebugContext::PrintStatistics
}\label{wxdebugcontextprintstatistics
}
131 \func{bool
}{PrintStatistics
}{\param{bool
}{ detailed = TRUE
}}
133 Performs a statistics analysis from the currently set checkpoint, writing
134 to the current debug stream. The number of object and non-object
135 allocations is printed, together with the total size.
137 \wxheading{Parameters
}
139 \docparam{detailed
}{If TRUE, the function will also print how many
140 objects of each class have been allocated, and the space taken by
141 these class instances.
}
145 \helpref{wxDebugContext::PrintStatistics
}{wxdebugcontextprintstatistics
}
147 \membersection{wxDebugContext::SetCheckpoint
}\label{wxdebugcontextsetcheckpoint
}
149 \func{void
}{SetCheckpoint
}{\param{bool
}{ all = FALSE
}}
151 Sets the current checkpoint: Dump and PrintStatistics operations will
152 be performed from this point on. This allows you to ignore allocations
153 that have been performed up to this point.
155 \wxheading{Parameters
}
157 \docparam{all
}{If TRUE, the checkpoint is reset to include all
158 memory allocations since the program started.
}
160 \membersection{wxDebugContext::SetCheckPrevious
}\label{wxdebugcontextsetcheckprevious
}
162 \func{void
}{SetCheckPrevious
}{\param{bool
}{ check
}}
164 Tells the memory allocator to check all previous memory blocks for errors.
165 By default, this is FALSE since it slows down execution considerably.
169 \helpref{wxDebugContext::GetCheckPrevious
}{wxdebugcontextgetcheckprevious
}
171 \membersection{wxDebugContext::SetDebugMode
}\label{wxdebugcontextsetdebugmode
}
173 \func{void
}{SetDebugMode
}{\param{bool
}{ debug
}}
175 Sets the debug mode on or off. If debug mode is on, the wxObject new and delete
176 operators store or use information about memory allocation. Otherwise,
177 a straight malloc and free will be performed by these operators.
179 By default, debug mode is on if DEBUG is non-zero. If the application
180 uses this function, it should make sure that all object memory allocated
181 is deallocated with the same value of debug mode. Otherwise, the
182 delete operator might try to look for memory information that does not
187 \helpref{wxDebugContext::GetDebugMode
}{wxdebugcontextgetdebugmode
}
189 \membersection{wxDebugContext::SetFile
}\label{wxdebugcontextsetfile
}
191 \func{bool
}{SetFile
}{\param{const wxString\&
}{filename
}}
193 Sets the current debug file and creates a stream. This will delete any existing
194 stream and stream buffer. By default, the debug context stream
195 outputs to the debugger (Windows) or standard error (other platforms).
197 \membersection{wxDebugContext::SetLevel
}\label{wxdebugcontextsetlevel
}
199 \func{void
}{SetLevel
}{\param{int
}{ level
}}
201 Sets the debug level (default
1). The debug level is used by the wxTraceLevel function and
202 the WXTRACELEVEL macro to specify how detailed the trace information is; setting
203 a different level will only have an effect if trace statements in the application
204 specify a value other than one.
206 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
210 \helpref{wxDebugContext::GetLevel
}{wxdebugcontextgetlevel
}
212 \membersection{wxDebugContext::SetStandardError
}\label{wxdebugcontextsetstandarderror
}
214 \func{bool
}{SetStandardError
}{\void}
216 Sets the debugging stream to be the debugger (Windows) or standard error (other platforms).
217 This is the default setting. The existing stream will be flushed and deleted.
219 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
221 \membersection{wxDebugContext::SetStream
}\label{wxdebugcontextsetstream
}
223 \func{void
}{SetStream
}{\param{ostream*
}{stream
},
\param{streambuf*
}{streamBuf = NULL
}}
225 Sets the stream and optionally, stream buffer associated with the debug context.
226 This operation flushes and deletes the existing stream (and stream buffer if any).
228 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
230 \wxheading{Parameters
}
232 \docparam{stream
}{Stream to associate with the debug context. Do not set this to NULL.
}
234 \docparam{streamBuf
}{Stream buffer to associate with the debug context.
}
238 \helpref{wxDebugContext::GetStream
}{wxdebugcontextgetstream
},
\helpref{wxDebugContext::HasStream
}{wxdebugcontexthasstream
}
240 \section{\class{wxDebugStreamBuf
}}\label{wxdebugstreambuf
}
242 This class allows you to treat debugging output in a similar
243 (stream-based) fashion on different platforms. Under
244 Windows, an ostream constructed with this buffer outputs
245 to the debugger, or other program that intercepts debugging
246 output. On other platforms, the output goes to standard error (cerr).
248 This is soon to be obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
250 \wxheading{Derived from
}
257 wxDebugStreamBuf streamBuf;
258 ostream stream(&streamBuf);
260 stream << "Hello world!" << endl;
265 \overview{Overview
}{wxdebugcontextoverview
}