]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxDebugContext}}\label{wxdebugcontext} |
2 | ||
3 | A class for performing various debugging and memory tracing | |
4 | operations. Full functionality (such as printing out objects | |
fc2171bd | 5 | currently allocated) is only present in a debugging build of wxWidgets, |
fe26d444 | 6 | i.e. if the \_\_WXDEBUG\_\_ symbol is defined. wxDebugContext |
a660d684 | 7 | and related functions and macros can be compiled out by setting |
9a05fd8d | 8 | wxUSE\_DEBUG\_CONTEXT to 0 is setup.h |
a660d684 KB |
9 | |
10 | \wxheading{Derived from} | |
11 | ||
12 | No parent class. | |
13 | ||
954b8ae6 JS |
14 | \wxheading{Include files} |
15 | ||
16 | <wx/memory.h> | |
17 | ||
a7af285d VZ |
18 | \wxheading{Library} |
19 | ||
20 | \helpref{wxBase}{librarieslist} | |
21 | ||
a660d684 KB |
22 | \wxheading{See also} |
23 | ||
24 | \overview{Overview}{wxdebugcontextoverview} | |
25 | ||
26 | \latexignore{\rtfignore{\wxheading{Members}}} | |
27 | ||
28 | \membersection{wxDebugContext::Check}\label{wxdebugcontextcheck} | |
29 | ||
30 | \func{int}{Check}{\void} | |
31 | ||
32 | Checks the memory blocks for errors, starting from the currently set | |
33 | checkpoint. | |
34 | ||
35 | \wxheading{Return value} | |
36 | ||
37 | Returns the number of errors, | |
38 | so a value of zero represents success. Returns -1 if an error | |
39 | was detected that prevents further checking. | |
40 | ||
41 | \membersection{wxDebugContext::Dump}\label{wxdebugcontextdump} | |
42 | ||
43 | \func{bool}{Dump}{\void} | |
44 | ||
45 | Performs a memory dump from the currently set checkpoint, writing to the | |
46 | current debug stream. Calls the {\bf Dump} member function for each wxObject | |
47 | derived instance. | |
48 | ||
49 | \wxheading{Return value} | |
50 | ||
cc81d32f | 51 | true if the function succeeded, false otherwise. |
a660d684 KB |
52 | |
53 | \membersection{wxDebugContext::GetCheckPrevious}\label{wxdebugcontextgetcheckprevious} | |
54 | ||
55 | \func{bool}{GetCheckPrevious}{\void} | |
56 | ||
cc81d32f VS |
57 | Returns true if the memory allocator checks all previous memory blocks for errors. |
58 | By default, this is false since it slows down execution considerably. | |
a660d684 KB |
59 | |
60 | \wxheading{See also} | |
61 | ||
62 | \helpref{wxDebugContext::SetCheckPrevious}{wxdebugcontextsetcheckprevious} | |
63 | ||
64 | \membersection{wxDebugContext::GetDebugMode}\label{wxdebugcontextgetdebugmode} | |
65 | ||
66 | \func{bool}{GetDebugMode}{\void} | |
67 | ||
cc81d32f | 68 | Returns true if debug mode is on. If debug mode is on, the wxObject new and delete |
a660d684 KB |
69 | operators store or use information about memory allocation. Otherwise, |
70 | a straight malloc and free will be performed by these operators. | |
71 | ||
72 | \wxheading{See also} | |
73 | ||
74 | \helpref{wxDebugContext::SetDebugMode}{wxdebugcontextsetdebugmode} | |
75 | ||
76 | \membersection{wxDebugContext::GetLevel}\label{wxdebugcontextgetlevel} | |
77 | ||
78 | \func{int}{GetLevel}{\void} | |
79 | ||
80 | Gets the debug level (default 1). The debug level is used by the wxTraceLevel function and | |
81 | the WXTRACELEVEL macro to specify how detailed the trace information is; setting | |
82 | a different level will only have an effect if trace statements in the application | |
83 | specify a value other than one. | |
84 | ||
6fb26ea3 JS |
85 | This is obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
86 | ||
a660d684 KB |
87 | \wxheading{See also} |
88 | ||
89 | \helpref{wxDebugContext::SetLevel}{wxdebugcontextsetlevel} | |
90 | ||
91 | \membersection{wxDebugContext::GetStream}\label{wxdebugcontextgetstream} | |
92 | ||
93 | \func{ostream\&}{GetStream}{\void} | |
94 | ||
95 | Returns the output stream associated with the debug context. | |
96 | ||
6fb26ea3 JS |
97 | This is obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
98 | ||
a660d684 KB |
99 | \wxheading{See also} |
100 | ||
101 | \helpref{wxDebugContext::SetStream}{wxdebugcontextsetstream} | |
102 | ||
103 | \membersection{wxDebugContext::GetStreamBuf}\label{wxdebugcontextgetstreambuf} | |
104 | ||
105 | \func{streambuf*}{GetStreamBuf}{\void} | |
106 | ||
107 | Returns a pointer to the output stream buffer associated with the debug context. | |
108 | There may not necessarily be a stream buffer if the stream has been set | |
109 | by the user. | |
110 | ||
6fb26ea3 JS |
111 | This is obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
112 | ||
a660d684 KB |
113 | \membersection{wxDebugContext::HasStream}\label{wxdebugcontexthasstream} |
114 | ||
115 | \func{bool}{HasStream}{\void} | |
116 | ||
cc81d32f | 117 | Returns true if there is a stream currently associated |
a660d684 KB |
118 | with the debug context. |
119 | ||
6fb26ea3 JS |
120 | This is obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
121 | ||
a660d684 KB |
122 | \wxheading{See also} |
123 | ||
124 | \helpref{wxDebugContext::SetStream}{wxdebugcontextsetstream}, \helpref{wxDebugContext::GetStream}{wxdebugcontextgetstream} | |
125 | ||
126 | \membersection{wxDebugContext::PrintClasses}\label{wxdebugcontextprintclasses} | |
127 | ||
128 | \func{bool}{PrintClasses}{\void} | |
129 | ||
130 | Prints a list of the classes declared in this application, giving derivation | |
131 | and whether instances of this class can be dynamically created. | |
132 | ||
133 | \wxheading{See also} | |
134 | ||
135 | \helpref{wxDebugContext::PrintStatistics}{wxdebugcontextprintstatistics} | |
136 | ||
137 | \membersection{wxDebugContext::PrintStatistics}\label{wxdebugcontextprintstatistics} | |
138 | ||
cc81d32f | 139 | \func{bool}{PrintStatistics}{\param{bool}{ detailed = true}} |
a660d684 KB |
140 | |
141 | Performs a statistics analysis from the currently set checkpoint, writing | |
142 | to the current debug stream. The number of object and non-object | |
143 | allocations is printed, together with the total size. | |
144 | ||
145 | \wxheading{Parameters} | |
146 | ||
cc81d32f | 147 | \docparam{detailed}{If true, the function will also print how many |
a660d684 KB |
148 | objects of each class have been allocated, and the space taken by |
149 | these class instances.} | |
150 | ||
151 | \wxheading{See also} | |
152 | ||
153 | \helpref{wxDebugContext::PrintStatistics}{wxdebugcontextprintstatistics} | |
154 | ||
155 | \membersection{wxDebugContext::SetCheckpoint}\label{wxdebugcontextsetcheckpoint} | |
156 | ||
cc81d32f | 157 | \func{void}{SetCheckpoint}{\param{bool}{ all = false}} |
a660d684 KB |
158 | |
159 | Sets the current checkpoint: Dump and PrintStatistics operations will | |
160 | be performed from this point on. This allows you to ignore allocations | |
161 | that have been performed up to this point. | |
162 | ||
163 | \wxheading{Parameters} | |
164 | ||
cc81d32f | 165 | \docparam{all}{If true, the checkpoint is reset to include all |
a660d684 KB |
166 | memory allocations since the program started.} |
167 | ||
168 | \membersection{wxDebugContext::SetCheckPrevious}\label{wxdebugcontextsetcheckprevious} | |
169 | ||
170 | \func{void}{SetCheckPrevious}{\param{bool}{ check}} | |
171 | ||
172 | Tells the memory allocator to check all previous memory blocks for errors. | |
cc81d32f | 173 | By default, this is false since it slows down execution considerably. |
a660d684 KB |
174 | |
175 | \wxheading{See also} | |
176 | ||
177 | \helpref{wxDebugContext::GetCheckPrevious}{wxdebugcontextgetcheckprevious} | |
178 | ||
179 | \membersection{wxDebugContext::SetDebugMode}\label{wxdebugcontextsetdebugmode} | |
180 | ||
181 | \func{void}{SetDebugMode}{\param{bool}{ debug}} | |
182 | ||
183 | Sets the debug mode on or off. If debug mode is on, the wxObject new and delete | |
184 | operators store or use information about memory allocation. Otherwise, | |
185 | a straight malloc and free will be performed by these operators. | |
186 | ||
fe26d444 | 187 | By default, debug mode is on if \_\_WXDEBUG\_\_ is defined. If the application |
a660d684 KB |
188 | uses this function, it should make sure that all object memory allocated |
189 | is deallocated with the same value of debug mode. Otherwise, the | |
190 | delete operator might try to look for memory information that does not | |
191 | exist. | |
192 | ||
193 | \wxheading{See also} | |
194 | ||
195 | \helpref{wxDebugContext::GetDebugMode}{wxdebugcontextgetdebugmode} | |
196 | ||
197 | \membersection{wxDebugContext::SetFile}\label{wxdebugcontextsetfile} | |
198 | ||
199 | \func{bool}{SetFile}{\param{const wxString\& }{filename}} | |
200 | ||
201 | Sets the current debug file and creates a stream. This will delete any existing | |
202 | stream and stream buffer. By default, the debug context stream | |
203 | outputs to the debugger (Windows) or standard error (other platforms). | |
204 | ||
205 | \membersection{wxDebugContext::SetLevel}\label{wxdebugcontextsetlevel} | |
206 | ||
207 | \func{void}{SetLevel}{\param{int}{ level}} | |
208 | ||
209 | Sets the debug level (default 1). The debug level is used by the wxTraceLevel function and | |
210 | the WXTRACELEVEL macro to specify how detailed the trace information is; setting | |
211 | a different level will only have an effect if trace statements in the application | |
212 | specify a value other than one. | |
213 | ||
6fb26ea3 JS |
214 | This is obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
215 | ||
a660d684 KB |
216 | \wxheading{See also} |
217 | ||
218 | \helpref{wxDebugContext::GetLevel}{wxdebugcontextgetlevel} | |
219 | ||
220 | \membersection{wxDebugContext::SetStandardError}\label{wxdebugcontextsetstandarderror} | |
221 | ||
222 | \func{bool}{SetStandardError}{\void} | |
223 | ||
224 | Sets the debugging stream to be the debugger (Windows) or standard error (other platforms). | |
225 | This is the default setting. The existing stream will be flushed and deleted. | |
226 | ||
6fb26ea3 JS |
227 | This is obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
228 | ||
a660d684 KB |
229 | \membersection{wxDebugContext::SetStream}\label{wxdebugcontextsetstream} |
230 | ||
231 | \func{void}{SetStream}{\param{ostream* }{stream}, \param{streambuf* }{streamBuf = NULL}} | |
232 | ||
233 | Sets the stream and optionally, stream buffer associated with the debug context. | |
234 | This operation flushes and deletes the existing stream (and stream buffer if any). | |
235 | ||
6fb26ea3 JS |
236 | This is obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
237 | ||
a660d684 KB |
238 | \wxheading{Parameters} |
239 | ||
240 | \docparam{stream}{Stream to associate with the debug context. Do not set this to NULL.} | |
241 | ||
242 | \docparam{streamBuf}{Stream buffer to associate with the debug context.} | |
243 | ||
244 | \wxheading{See also} | |
245 | ||
246 | \helpref{wxDebugContext::GetStream}{wxdebugcontextgetstream}, \helpref{wxDebugContext::HasStream}{wxdebugcontexthasstream} | |
247 | ||
248 | \section{\class{wxDebugStreamBuf}}\label{wxdebugstreambuf} | |
249 | ||
250 | This class allows you to treat debugging output in a similar | |
251 | (stream-based) fashion on different platforms. Under | |
252 | Windows, an ostream constructed with this buffer outputs | |
253 | to the debugger, or other program that intercepts debugging | |
254 | output. On other platforms, the output goes to standard error (cerr). | |
255 | ||
6fb26ea3 JS |
256 | This is soon to be obsolete, replaced by \helpref{wxLog}{wxlog} functionality. |
257 | ||
a660d684 KB |
258 | \wxheading{Derived from} |
259 | ||
260 | streambuf | |
261 | ||
954b8ae6 JS |
262 | \wxheading{Include files} |
263 | ||
264 | <wx/memory.h> | |
265 | ||
a660d684 KB |
266 | \wxheading{Example} |
267 | ||
268 | \begin{verbatim} | |
269 | wxDebugStreamBuf streamBuf; | |
270 | ostream stream(&streamBuf); | |
271 | ||
272 | stream << "Hello world!" << endl; | |
273 | \end{verbatim} | |
274 | ||
275 | \wxheading{See also} | |
276 | ||
277 | \overview{Overview}{wxdebugcontextoverview} | |
278 | ||
279 |